Fix integration branch
This commit is contained in:
parent
cd94cc91c7
commit
d3f7d7bd76
|
@ -6,7 +6,7 @@ import { DutchAuctionBlock } from '../Common/DutchAuctionBlock'
|
|||
import { Field, FormSpy } from 'react-final-form'
|
||||
import { FieldArray } from 'react-final-form-arrays'
|
||||
import { InputField2 } from '../Common/InputField2'
|
||||
import { DESCRIPTION, TEXT_FIELDS, VALIDATION_MESSAGES, VALIDATION_TYPES } from '../../utils/constants'
|
||||
import { TEXT_FIELDS, VALIDATION_TYPES, VALIDATION_MESSAGES, DESCRIPTION } from '../../utils/constants'
|
||||
import { WhenFieldChanges } from '../Common/WhenFieldChanges'
|
||||
import {
|
||||
composeValidators,
|
||||
|
@ -24,7 +24,6 @@ export const StepThreeFormDutchAuction = ({
|
|||
errors,
|
||||
form,
|
||||
handleSubmit,
|
||||
history,
|
||||
invalid,
|
||||
pristine,
|
||||
firstLoad,
|
||||
|
@ -37,11 +36,11 @@ export const StepThreeFormDutchAuction = ({
|
|||
const { setFieldTouched } = form.mutators
|
||||
|
||||
const handleValidateGasPrice = value => {
|
||||
const errors = composeValidators(
|
||||
const hasErrors = composeValidators(
|
||||
isDecimalPlacesNotGreaterThan(VALIDATION_MESSAGES.DECIMAL_PLACES_9)(9),
|
||||
isGreaterOrEqualThan(VALIDATION_MESSAGES.NUMBER_GREATER_OR_EQUAL_THAN)(0.1)
|
||||
isGreaterOrEqualThan(`${VALIDATION_MESSAGES.NUMBER_GREATER_OR_EQUAL_THAN} 0.1`)(0.1)
|
||||
)(value.price)
|
||||
if (errors) return errors.shift()
|
||||
if (hasErrors) return hasErrors.shift()
|
||||
}
|
||||
|
||||
const handleBurnExcessChange = (value, input) => {
|
||||
|
@ -70,7 +69,7 @@ export const StepThreeFormDutchAuction = ({
|
|||
|
||||
const handleOnChange = ({ values }) => {
|
||||
const { tierStore, generalStore, crowdsaleStore } = props
|
||||
const { walletAddress, gasPrice, burnExcess, tiers } = values
|
||||
const { walletAddress, gasPrice, tiers, burnExcess } = values
|
||||
|
||||
tierStore.updateWalletAddress(walletAddress, VALID)
|
||||
tierStore.updateBurnExcess(burnExcess, VALID)
|
||||
|
@ -140,7 +139,7 @@ export const StepThreeFormDutchAuction = ({
|
|||
component={GasPriceInput}
|
||||
gasPrices={props.gasPriceStore.gasPricesInGwei}
|
||||
name="gasPrice"
|
||||
updateGasTypeSelected={value => props.updateGasTypeSelected(value)}
|
||||
updateGasTypeSelected={value => props.generalStore.setGasTypeSelected(value)}
|
||||
validate={value => handleValidateGasPrice(value)}
|
||||
id="gasPrice"
|
||||
side="right"
|
||||
|
|
|
@ -24,7 +24,6 @@ export const StepThreeFormMintedCapped = ({
|
|||
errors,
|
||||
form,
|
||||
handleSubmit,
|
||||
history,
|
||||
invalid,
|
||||
pristine,
|
||||
firstLoad,
|
||||
|
@ -52,7 +51,7 @@ export const StepThreeFormMintedCapped = ({
|
|||
}
|
||||
|
||||
const setFieldAsTouched = ({ values }) => {
|
||||
if (!firstLoad) {
|
||||
if (firstLoad) {
|
||||
values.tiers.forEach((tier, index) => {
|
||||
setFieldTouched(`tiers[${index}].tier`, true)
|
||||
setFieldTouched(`tiers[${index}].updatable`, true)
|
||||
|
|
|
@ -37,7 +37,7 @@ export class StepThree extends Component {
|
|||
gasTypeSelected: {}
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
componentDidMount() {
|
||||
const { web3Store, gasPriceStore } = this.props
|
||||
|
||||
checkWeb3(web3Store.web3)
|
||||
|
@ -194,7 +194,6 @@ export class StepThree extends Component {
|
|||
<Form
|
||||
component={stepThreeComponent}
|
||||
decorators={[this.calculator]}
|
||||
history={this.props.history}
|
||||
initialValues={{
|
||||
burnExcess: this.state.burnExcess,
|
||||
gasPrice: this.state.gasTypeSelected,
|
||||
|
|
|
@ -69,42 +69,4 @@ describe('StepThreeFormDutchAuction', () => {
|
|||
// Then
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it(`should call updateGasTypeSelected`, () => {
|
||||
// Given
|
||||
const updateGasTypeSelected = jest.fn()
|
||||
const wrapper = mount(
|
||||
<Provider {...stores}>
|
||||
<Form
|
||||
onSubmit={jest.fn()}
|
||||
decorators={[jest.fn()]}
|
||||
initialValues={{
|
||||
gasPrice: GAS_PRICE.SLOW,
|
||||
tiers: tierStore.tiers.slice(),
|
||||
walletAddress: walletAddress,
|
||||
whitelistEnabled: 'no'
|
||||
}}
|
||||
mutators={{ ...arrayMutators, setFieldTouched }}
|
||||
history={{ push: jest.fn() }}
|
||||
firstLoad={false}
|
||||
updateGasTypeSelected={updateGasTypeSelected}
|
||||
component={StepThreeFormDutchAuction}
|
||||
{...stores}
|
||||
/>
|
||||
</Provider>
|
||||
)
|
||||
const fast = gasPriceStore.gasPrices[2]
|
||||
fast.price = weiToGwei(fast.price)
|
||||
|
||||
// When
|
||||
wrapper
|
||||
.find('.sw-GasPriceInput_SelectInput')
|
||||
.find(`[value="${GAS_PRICE.FAST.id}"]`)
|
||||
.simulate('click')
|
||||
|
||||
// Then
|
||||
expect(updateGasTypeSelected).toHaveBeenCalled()
|
||||
expect(updateGasTypeSelected).toHaveBeenCalledTimes(1)
|
||||
expect(updateGasTypeSelected).toHaveBeenCalledWith(fast)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -551,7 +551,7 @@ exports[`StepThreeFormDutchAuction should render StepThreeFormDutchAuction 1`] =
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
onClick={[Function]}
|
||||
disabled={true}
|
||||
type="button"
|
||||
>
|
||||
Back
|
||||
|
|
|
@ -310,6 +310,25 @@ exports[`StepThreeFormMintedCapped should render StepThreeFormMintedCapped 1`] =
|
|||
type="number"
|
||||
value=""
|
||||
/>
|
||||
<div
|
||||
className="sw-Errors"
|
||||
>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Please enter a valid number greater than 0
|
||||
</div>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Should be integer
|
||||
</div>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Should not be greater than 1 quintillion (10^18)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="sw-InputField2 sw-InputField2-CrowdsaleSupply"
|
||||
|
@ -346,6 +365,15 @@ exports[`StepThreeFormMintedCapped should render StepThreeFormMintedCapped 1`] =
|
|||
type="number"
|
||||
value=""
|
||||
/>
|
||||
<div
|
||||
className="sw-Errors"
|
||||
>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Please enter a valid number greater than 0
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="sw-InputField2 sw-InputField2-MinCap"
|
||||
|
@ -384,6 +412,15 @@ exports[`StepThreeFormMintedCapped should render StepThreeFormMintedCapped 1`] =
|
|||
type="number"
|
||||
value="0"
|
||||
/>
|
||||
<div
|
||||
className="sw-Errors"
|
||||
>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Decimals should not exceed undefined places
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="sw-RadioButton sw-InputField2-WhitelistEnabled"
|
||||
|
@ -534,7 +571,7 @@ exports[`StepThreeFormMintedCapped should render StepThreeFormMintedCapped 1`] =
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
onClick={[Function]}
|
||||
disabled={true}
|
||||
type="button"
|
||||
>
|
||||
Back
|
||||
|
|
|
@ -636,6 +636,7 @@ exports[`StepThree StepThree - renders should render StepThree for Dutch Auction
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
|
@ -1116,25 +1117,6 @@ exports[`StepThree StepThree - renders should render StepThree for Whitelist wit
|
|||
type="number"
|
||||
value=""
|
||||
/>
|
||||
<div
|
||||
className="sw-Errors"
|
||||
>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Please enter a valid number greater than 0
|
||||
</div>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Should be integer
|
||||
</div>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Should not be greater than 1 quintillion (10^18)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="sw-InputField2 sw-InputField2-CrowdsaleSupply"
|
||||
|
@ -1171,15 +1153,6 @@ exports[`StepThree StepThree - renders should render StepThree for Whitelist wit
|
|||
type="number"
|
||||
value=""
|
||||
/>
|
||||
<div
|
||||
className="sw-Errors"
|
||||
>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Please enter a valid number greater than 0
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="sw-InputField2 sw-InputField2-MinCap"
|
||||
|
@ -1218,15 +1191,6 @@ exports[`StepThree StepThree - renders should render StepThree for Whitelist wit
|
|||
type="number"
|
||||
value="0"
|
||||
/>
|
||||
<div
|
||||
className="sw-Errors"
|
||||
>
|
||||
<div
|
||||
className="sw-Errors_Item"
|
||||
>
|
||||
Decimals should not exceed undefined places
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="sw-RadioButton sw-InputField2-WhitelistEnabled"
|
||||
|
@ -1377,6 +1341,7 @@ exports[`StepThree StepThree - renders should render StepThree for Whitelist wit
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
|
|
|
@ -155,7 +155,7 @@ exports[`StepTwoForm should render StepTwoForm for Dutch Auction Crowdsale 1`] =
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
onClick={[Function]}
|
||||
disabled={true}
|
||||
type="button"
|
||||
>
|
||||
Back
|
||||
|
@ -456,7 +456,7 @@ exports[`StepTwoForm should render StepTwoForm for Minted Capped Crowdsale 1`] =
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
onClick={[Function]}
|
||||
disabled={true}
|
||||
type="button"
|
||||
>
|
||||
Back
|
||||
|
|
|
@ -276,6 +276,7 @@ exports[`StepTwo should render StepTwo for Dutch Auction strategy 1`] = `
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
|
@ -540,6 +541,7 @@ exports[`StepTwo should render StepTwo for Minted Capped strategy 1`] = `
|
|||
>
|
||||
<button
|
||||
className="sw-ButtonBack "
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
|
|
|
@ -175,36 +175,6 @@ describe('Utils', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('objectKeysToLowerCase', () => {
|
||||
it(`should return an object with all keys in lower case`, () => {
|
||||
// Given
|
||||
const collection = [
|
||||
{
|
||||
KEY_UPPERCASED: ['thing', 'Another thing'],
|
||||
KEY_Mixed: 'a value'
|
||||
},
|
||||
['this is a mixed thing', { KEY: 'will it cast this key as well?' }],
|
||||
{
|
||||
ANOTHER_KEY: 'text'
|
||||
}
|
||||
]
|
||||
const expectedResult = [
|
||||
{
|
||||
key_uppercased: ['thing', 'Another thing'],
|
||||
key_mixed: 'a value'
|
||||
},
|
||||
['this is a mixed thing', { key: 'will it cast this key as well?' }],
|
||||
{ another_key: 'text' }
|
||||
]
|
||||
|
||||
// When
|
||||
const collectionToLowercase = objectKeysToLowerCase(collection)
|
||||
|
||||
// Then
|
||||
expect(collectionToLowercase).toEqual(expectedResult)
|
||||
})
|
||||
})
|
||||
|
||||
describe('validateTier', () => {
|
||||
const testCases = [
|
||||
{ value: 'really long string that will not pass the validation', expected: false },
|
||||
|
|
Loading…
Reference in New Issue