From 887a48480f84f6335dd8a94f49b7cebe3bc0789e Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Mon, 12 Nov 2018 12:52:39 -0300
Subject: [PATCH 01/30] Add utils test
---
src/components/Home/utils.js | 8 +++++++-
test/components/Home/utils.spec.js | 31 ++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
create mode 100644 test/components/Home/utils.spec.js
diff --git a/src/components/Home/utils.js b/src/components/Home/utils.js
index f64360fc1..4bcaeddb3 100644
--- a/src/components/Home/utils.js
+++ b/src/components/Home/utils.js
@@ -9,6 +9,9 @@ export const reloadStorage = async props => {
let { generalStore, contractStore } = props
try {
+ if (!contractStore || !generalStore) {
+ throw new Error('There is no stores to set')
+ }
contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.PENDING)
// General store, check network
@@ -18,9 +21,12 @@ export const reloadStorage = async props => {
// Contract store, get contract and abi
await getCrowdsaleAssets(networkID)
contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.SUCCESS)
+ return true
} catch (e) {
logger.error('Error downloading contracts', e)
- contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.FAILURE)
+ if (contractStore) {
+ contractStore.setProperty('downloadStatus', DOWNLOAD_STATUS.FAILURE)
+ }
throw e
}
}
diff --git a/test/components/Home/utils.spec.js b/test/components/Home/utils.spec.js
new file mode 100644
index 000000000..f2ce5c8c9
--- /dev/null
+++ b/test/components/Home/utils.spec.js
@@ -0,0 +1,31 @@
+import React from 'react'
+import Adapter from 'enzyme-adapter-react-15'
+import { configure } from 'enzyme'
+import { reloadStorage } from '../../../src/components/Home/utils'
+import { generalStore, contractStore } from '../../../src/stores/index'
+
+configure({ adapter: new Adapter() })
+
+describe('Home utils', () => {
+ const data = {
+ generalStore: generalStore,
+ contractStore: contractStore
+ }
+
+ it('Test reloadStorage with data', async () => {
+ const result = await reloadStorage(data)
+ expect(result).toBeTruthy()
+ })
+
+ it('Test reloadStorage with empty data', async () => {
+ expect(reloadStorage({})).rejects.toEqual(new Error('There is no stores to set'))
+ })
+
+ it('Test reloadStorage with only generalStore', async () => {
+ expect(reloadStorage({ generalStore: generalStore })).rejects.toEqual(new Error('There is no stores to set'))
+ })
+
+ it('Test reloadStorage with only contractStore', async () => {
+ expect(reloadStorage({ contractStore: contractStore })).rejects.toEqual(new Error('There is no stores to set'))
+ })
+})
From 8d5daa3b9db55ae57f2b26e010d4119a379183b6 Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Mon, 12 Nov 2018 12:53:08 -0300
Subject: [PATCH 02/30] Refactor fectch file
---
src/utils/fetchFile.js | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/utils/fetchFile.js b/src/utils/fetchFile.js
index 5ca5b6500..cbe421968 100644
--- a/src/utils/fetchFile.js
+++ b/src/utils/fetchFile.js
@@ -1,15 +1,5 @@
-export function fetchFile(path) {
- return new Promise((resolve, reject) => {
- const rawFile = new XMLHttpRequest()
-
- rawFile.addEventListener('error', reject)
- rawFile.open('GET', path, true)
- rawFile.onreadystatechange = function() {
- if (rawFile.readyState === 4 && (rawFile.status === 200 || rawFile.status === 0)) {
- let allText = rawFile.responseText
- resolve(allText)
- }
- }
- rawFile.send(null)
- })
+export async function fetchFile(path) {
+ let response = await fetch(path)
+ let data = await response.text()
+ return data
}
From 1b1ed23fc2f366bf931c14354e31ebf5650bd48b Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Mon, 12 Nov 2018 12:53:36 -0300
Subject: [PATCH 03/30] Remove functions
---
src/stores/utils.js | 8 ++++----
src/utils/blockchainHelpers.js | 24 ++++++++++++------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/stores/utils.js b/src/stores/utils.js
index 71f851388..36cf70ce0 100644
--- a/src/stores/utils.js
+++ b/src/stores/utils.js
@@ -49,15 +49,15 @@ export const getCrowdsaleAssets = async networkID => {
return Promise.all(whenPromises)
}
-async function getCrowdsaleAsset(contractName, stateProp, networkID) {
+const getCrowdsaleAsset = async (contractName, stateProp, networkID) => {
logger.log(contractName, stateProp, networkID)
const whenSrc =
stateProp === 'MintedCappedProxy' || stateProp === 'DutchProxy'
- ? setFlatFileContentToState(`./contracts/${stateProp}.sol`)
+ ? await setFlatFileContentToState(`./contracts/${stateProp}.sol`)
: Promise.resolve()
const whenBin =
stateProp === 'MintedCappedProxy' || stateProp === 'DutchProxy'
- ? setFlatFileContentToState(`./contracts/${stateProp}.bin`)
+ ? await setFlatFileContentToState(`./contracts/${stateProp}.bin`)
: Promise.resolve()
let abi
//todo: get ABI or from file or from here
@@ -2553,7 +2553,7 @@ async function getCrowdsaleAsset(contractName, stateProp, networkID) {
Promise.resolve()
}
-function addContractsToState(src, bin, abi, addr, contract) {
+const addContractsToState = (src, bin, abi, addr, contract) => {
contractStore.setContract(contract, {
src,
bin,
diff --git a/src/utils/blockchainHelpers.js b/src/utils/blockchainHelpers.js
index 5bddd009e..8cd6554d1 100644
--- a/src/utils/blockchainHelpers.js
+++ b/src/utils/blockchainHelpers.js
@@ -362,7 +362,7 @@ const getTypeOfTxDisplayName = type => {
}
}
-export function attachToContract(abi, addr) {
+export const attachToContract = (abi, addr) => {
const { web3 } = web3Store
return web3.eth.getAccounts().then(accounts => {
@@ -386,7 +386,7 @@ const getApplicationInstance = async (app_instances, appName, appNameHash, i) =>
}
}
-async function getAllApplicationsInstances() {
+const getAllApplicationsInstances = async () => {
const whenRegistryExecContract = attachToSpecificCrowdsaleContract('registryExec')
const {
REACT_APP_MINTED_CAPPED_APP_NAME: MINTED_CAPPED_APP_NAME,
@@ -414,7 +414,7 @@ async function getAllApplicationsInstances() {
return Promise.all(whenCrowdsales).then(crowdsales => crowdsales.filter(crowdsale => crowdsale !== null))
}
-async function getOwnerApplicationsInstancesForProxy() {
+const getOwnerApplicationsInstancesForProxy = async () => {
const { web3 } = web3Store
const proxiesRegistryContract = await attachToSpecificCrowdsaleContract('ProxiesRegistry')
const accounts = await web3.eth.getAccounts()
@@ -447,7 +447,7 @@ async function getOwnerApplicationsInstancesForProxy() {
}
// eslint-disable-next-line no-unused-vars
-async function getOwnerApplicationsInstances() {
+const getOwnerApplicationsInstances = async () => {
const { web3 } = web3Store
const registryExecContract = await attachToSpecificCrowdsaleContract('registryExec')
const accounts = await web3.eth.getAccounts()
@@ -545,13 +545,13 @@ export const getCrowdsaleStrategyByName = async appName => {
}
}
-export async function loadRegistryAddresses() {
+export const loadRegistryAddresses = async () => {
const crowdsales = await getOwnerApplicationsInstancesForProxy()
logger.log('Crowdsales', crowdsales)
crowdsaleStore.setCrowdsales(crowdsales)
}
-export let getCurrentAccount = () => {
+export const getCurrentAccount = () => {
const { web3 } = web3Store
return new Promise((resolve, reject) => {
if (!web3) {
@@ -704,27 +704,27 @@ export let methodToCreateAppInstance = (contractName, methodName, getEncodedPara
return method
}
-function getCrowdsaleInfo(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleInfo = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleInfo = initCrowdsaleContract.methods.getCrowdsaleInfo(addr, execID).call()
return whenCrowdsaleInfo
}
-function getCrowdsaleContributors(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleContributors = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleUniqueBuyers = initCrowdsaleContract.methods.getCrowdsaleUniqueBuyers(addr, execID).call()
return whenCrowdsaleUniqueBuyers
}
-function getCrowdsaleStartAndEndTimes(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleStartAndEndTimes = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleStartAndEndTimes = initCrowdsaleContract.methods.getCrowdsaleStartAndEndTimes(addr, execID).call()
return whenCrowdsaleStartAndEndTimes
}
-function getCrowdsaleTierList(initCrowdsaleContract, addr, execID) {
+const getCrowdsaleTierList = (initCrowdsaleContract, addr, execID) => {
const whenCrowdsaleTierList = initCrowdsaleContract.methods.getCrowdsaleTierList(addr, execID).call()
return whenCrowdsaleTierList
}
-export async function getAllCrowdsaleAddresses() {
+export const getAllCrowdsaleAddresses = async () => {
const instances = await getAllApplicationsInstances()
const targetPrefix = 'idx'
@@ -786,7 +786,7 @@ export const isAddressValid = addr => {
return web3Store && web3Store.web3 && web3Store.web3.utils.isAddress(addr)
}
-export function getProxyParams({ abstractStorageAddr, networkID, appNameHash }) {
+export const getProxyParams = ({ abstractStorageAddr, networkID, appNameHash }) => {
return [
abstractStorageAddr,
JSON.parse(process.env['REACT_APP_REGISTRY_EXEC_ID'] || '{}')[networkID],
From e1a22302383299393ca34a0960ab3609ad55436e Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Mon, 12 Nov 2018 16:20:30 -0300
Subject: [PATCH 04/30] Update tests for StepOne and Home components
---
src/components/StepOne/index.js | 14 +++-----
test/components/Home/utils.spec.js | 2 +-
test/components/StepOne/index.spec.js | 47 ++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/src/components/StepOne/index.js b/src/components/StepOne/index.js
index 17e08f698..6386e4eb7 100644
--- a/src/components/StepOne/index.js
+++ b/src/components/StepOne/index.js
@@ -118,15 +118,11 @@ export class StepOne extends Component {
}
goNextStep = () => {
- try {
- navigateTo({
- history: this.props.history,
- location: 'stepTwo',
- fromLocation: 'stepOne'
- })
- } catch (err) {
- logger.log('Error to navigate', err)
- }
+ navigateTo({
+ history: this.props.history,
+ location: 'stepTwo',
+ fromLocation: 'stepOne'
+ })
}
handleChange = e => {
diff --git a/test/components/Home/utils.spec.js b/test/components/Home/utils.spec.js
index f2ce5c8c9..81b99b3a0 100644
--- a/test/components/Home/utils.spec.js
+++ b/test/components/Home/utils.spec.js
@@ -13,7 +13,7 @@ describe('Home utils', () => {
}
it('Test reloadStorage with data', async () => {
- const result = await reloadStorage(data)
+ const result = async () => await reloadStorage(data)
expect(result).toBeTruthy()
})
diff --git a/test/components/StepOne/index.spec.js b/test/components/StepOne/index.spec.js
index 15e1fea1c..c792c0337 100644
--- a/test/components/StepOne/index.spec.js
+++ b/test/components/StepOne/index.spec.js
@@ -1,6 +1,6 @@
import React from 'react'
import Adapter from 'enzyme-adapter-react-15'
-import { configure, mount } from 'enzyme'
+import { configure, mount, shallow } from 'enzyme'
import renderer from 'react-test-renderer'
import { MemoryRouter } from 'react-router'
import { StepOne } from '../../../src/components/StepOne/index'
@@ -17,6 +17,7 @@ import {
tokenStore
} from '../../../src/stores'
import { CROWDSALE_STRATEGIES } from '../../../src/utils/constants'
+import GasPriceInput from '../../../src/components/StepThree/GasPriceInput'
configure({ adapter: new Adapter() })
@@ -106,4 +107,48 @@ describe('StepOne', () => {
// Then
expect(stepOneComponent.instance().state.strategy).toBe(MINTED_CAPPED_CROWDSALE)
})
+
+ it(`should render StepOne screen and test load method`, async () => {
+ // Given
+ const wrapper = shallow( )
+ // When
+ const result = await wrapper
+ .dive()
+ .instance()
+ .load()
+ // Then
+ expect(result).toEqual({ strategy: 'white-list-with-cap' })
+ })
+
+ it(`should render StepOne screen and test load method with clearStorage`, async () => {
+ // Given
+ global.localStorage.clearStorage = true
+ const wrapper = shallow( )
+ // When
+ const result = await wrapper
+ .dive()
+ .instance()
+ .load()
+ // Then
+ expect(result).toEqual({ strategy: 'white-list-with-cap' })
+ })
+
+ it(`should render StepOne screen and test reload`, async () => {
+ // Given
+ global.localStorage.reload = true
+ global.location = jest.fn()
+ global.location.assign = jest.fn()
+ const wrapper = mount( )
+
+ // When
+
+ expect(global.localStorage.reload).toBe(undefined)
+ expect(global.localStorage.clearStorage).toBeTruthy()
+ })
+
+ it(`should render StepOne screen and test beforeUnloadSpy`, async () => {
+ const wrapper = mount( )
+ window.location.reload()
+ expect(global.localStorage.reload).toBe(undefined)
+ })
})
From 73f8f0cf3fe49b0ee978800a804ff3a5642f83f9 Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Mon, 12 Nov 2018 21:05:51 -0300
Subject: [PATCH 05/30] Add tests for crowdsale, manage and stats
---
.../__snapshots__/index.spec.js.snap | 283 +++++++++++
test/components/Crowdsale/index.spec.js | 39 ++
.../manage/__snapshots__/index.spec.js.snap | 67 +++
test/components/manage/index.spec.js | 57 +++
.../stats/__snapshots__/index.spec.js.snap | 457 ++++++++++++++++++
test/components/stats/index.spec.js | 34 ++
6 files changed, 937 insertions(+)
create mode 100644 test/components/Crowdsale/__snapshots__/index.spec.js.snap
create mode 100644 test/components/Crowdsale/index.spec.js
create mode 100644 test/components/manage/__snapshots__/index.spec.js.snap
create mode 100644 test/components/manage/index.spec.js
create mode 100644 test/components/stats/__snapshots__/index.spec.js.snap
create mode 100644 test/components/stats/index.spec.js
diff --git a/test/components/Crowdsale/__snapshots__/index.spec.js.snap b/test/components/Crowdsale/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..b153128ca
--- /dev/null
+++ b/test/components/Crowdsale/__snapshots__/index.spec.js.snap
@@ -0,0 +1,283 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Crowdsale should render Crowdsale 1`] = `
+
+
+
+
+
+
+
+
+
+ Crowdsale Strategy
+
+
+
+
+
+
+
+ Crowdsale Setup
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+ ETH
+
+
+
+ Total Raised Funds
+
+
+
+
+ 0
+
+
+ ETH
+
+
+
+ Goal
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Crowdsale Proxy Address
+
+
+
+
+
+
+ Contribute
+
+
+
+
+
+
+
+`;
diff --git a/test/components/Crowdsale/index.spec.js b/test/components/Crowdsale/index.spec.js
new file mode 100644
index 000000000..a73923252
--- /dev/null
+++ b/test/components/Crowdsale/index.spec.js
@@ -0,0 +1,39 @@
+import React from 'react'
+import Adapter from 'enzyme-adapter-react-15'
+import { Provider } from 'mobx-react'
+import { configure } from 'enzyme'
+import renderer from 'react-test-renderer'
+import { MemoryRouter } from 'react-router'
+import {
+ contractStore,
+ crowdsaleStore,
+ crowdsalePageStore,
+ web3Store,
+ tierStore,
+ tokenStore,
+ generalStore
+} from '../../../src/stores'
+import { Crowdsale } from '../../../src/components/Crowdsale'
+
+configure({ adapter: new Adapter() })
+
+describe('Crowdsale index', () => {
+ const stores = { contractStore, crowdsaleStore, crowdsalePageStore, web3Store, tierStore, tokenStore, generalStore }
+
+ it(`should render Crowdsale`, () => {
+ // Given
+ const component = renderer.create(
+
+
+
+
+
+ )
+
+ // When
+ const tree = component.toJSON()
+
+ // Then
+ expect(tree).toMatchSnapshot()
+ })
+})
diff --git a/test/components/manage/__snapshots__/index.spec.js.snap b/test/components/manage/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..b65fe4568
--- /dev/null
+++ b/test/components/manage/__snapshots__/index.spec.js.snap
@@ -0,0 +1,67 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Manage should render Manage 1`] = `
+
+
+
+
+ !
+
+
+ Finalize Crowdsale
+
+
+ Finalize - Finalization is the last step of the crowdsale. You can make it only after the end of the last tier. After finalization, it's not possible to update tiers, buy tokens. All tokens will be movable, reserved tokens will be issued.
+
+
+
+ Finalize Crowdsale
+
+
+
+
+
+
+`;
diff --git a/test/components/manage/index.spec.js b/test/components/manage/index.spec.js
new file mode 100644
index 000000000..429c1af57
--- /dev/null
+++ b/test/components/manage/index.spec.js
@@ -0,0 +1,57 @@
+import React from 'react'
+import Adapter from 'enzyme-adapter-react-15'
+import { Provider } from 'mobx-react'
+import { configure } from 'enzyme'
+import renderer from 'react-test-renderer'
+import { MemoryRouter } from 'react-router'
+import { Manage } from '../../../src/components/manage/index'
+import {
+ crowdsaleStore,
+ web3Store,
+ tierStore,
+ contractStore,
+ reservedTokenStore,
+ stepTwoValidationStore,
+ generalStore,
+ tokenStore,
+ gasPriceStore,
+ deploymentStore
+} from '../../../src/stores'
+
+configure({ adapter: new Adapter() })
+
+describe('Manage index', () => {
+ const stores = {
+ crowdsaleStore,
+ web3Store,
+ tierStore,
+ contractStore,
+ reservedTokenStore,
+ stepTwoValidationStore,
+ generalStore,
+ tokenStore,
+ gasPriceStore,
+ deploymentStore
+ }
+
+ it(`should render Manage`, () => {
+ // Given
+ const data = {
+ params: { crowdsalePointer: 'test' }
+ }
+
+ const component = renderer.create(
+
+
+
+
+
+ )
+
+ // When
+ const tree = component.toJSON()
+
+ // Then
+ expect(tree).toMatchSnapshot()
+ })
+})
diff --git a/test/components/stats/__snapshots__/index.spec.js.snap b/test/components/stats/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..ed584c313
--- /dev/null
+++ b/test/components/stats/__snapshots__/index.spec.js.snap
@@ -0,0 +1,457 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Stats should render Stats 1`] = `
+
+
+ Token Wizard statistics
+
+
+
+
+
+
+ 0
+
+
+ Total crowdsales amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Total amount of eth raised
+
+
+
+
+
+
+
+
+ 0
+
+
+ Total contributors amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max amount of eth raised in one crowdsale
+
+
+
+
+
+
+ Minted capped crowdsales statistics
+
+
+
+
+
+
+ 0
+
+
+ Crowdsales amount
+
+
+
+
+ 0
+
+
+ Total amount of eth raised
+
+
+
+
+ 0
+
+
+ Total contributors amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Ongoing crowdsales amount
+
+
+
+
+ 0
+
+
+ Future crowdsales amount
+
+
+
+
+ 0
+
+
+ Past crowdsales amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max amount of eth raised in one crowdsale
+
+
+
+
+ 0
+
+
+ % of finalized crowdsales from ended
+
+
+
+
+ 0
+
+
+ % of crowdsales with multiple tiers
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max tiers amount in one crowdsale
+
+
+
+
+
+
+ Dutch auction crowdsales statistics
+
+
+
+
+
+
+ 0
+
+
+ Crowdsales amount
+
+
+
+
+ 0
+
+
+ Total amount of eth raised
+
+
+
+
+ 0
+
+
+ Total contributors amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Ongoing crowdsales amount
+
+
+
+
+ 0
+
+
+ Future crowdsales amount
+
+
+
+
+ 0
+
+
+ Past crowdsales amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max amount of eth raised in one crowdsale
+
+
+
+
+ 0
+
+
+ % of finalized crowdsales from ended
+
+
+
+
+
+
+
+`;
diff --git a/test/components/stats/index.spec.js b/test/components/stats/index.spec.js
new file mode 100644
index 000000000..8ca30e263
--- /dev/null
+++ b/test/components/stats/index.spec.js
@@ -0,0 +1,34 @@
+import React from 'react'
+import Adapter from 'enzyme-adapter-react-15'
+import { Provider } from 'mobx-react'
+import { configure } from 'enzyme'
+import renderer from 'react-test-renderer'
+import { MemoryRouter } from 'react-router'
+import { Stats } from '../../../src/components/stats/index'
+import { web3Store, statsStore } from '../../../src/stores'
+
+configure({ adapter: new Adapter() })
+
+describe('Stats index', () => {
+ const stores = {
+ web3Store,
+ statsStore
+ }
+
+ it(`should render Stats`, () => {
+ // Given
+ const component = renderer.create(
+
+
+
+
+
+ )
+
+ // When
+ const tree = component.toJSON()
+
+ // Then
+ expect(tree).toMatchSnapshot()
+ })
+})
From d98eb0b5efc60cda7081a7bb512e422ee6f03ed6 Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Tue, 13 Nov 2018 10:06:43 -0300
Subject: [PATCH 06/30] Update tests snapshots
---
test/components/Crowdsale/__snapshots__/index.spec.js.snap | 2 +-
test/components/manage/__snapshots__/index.spec.js.snap | 2 +-
test/components/stats/__snapshots__/index.spec.js.snap | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/components/Crowdsale/__snapshots__/index.spec.js.snap b/test/components/Crowdsale/__snapshots__/index.spec.js.snap
index b153128ca..9a524aef6 100644
--- a/test/components/Crowdsale/__snapshots__/index.spec.js.snap
+++ b/test/components/Crowdsale/__snapshots__/index.spec.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Crowdsale should render Crowdsale 1`] = `
+exports[`Crowdsale index should render Crowdsale 1`] = `
diff --git a/test/components/stats/__snapshots__/index.spec.js.snap b/test/components/stats/__snapshots__/index.spec.js.snap
index ed584c313..a57e5e1b0 100644
--- a/test/components/stats/__snapshots__/index.spec.js.snap
+++ b/test/components/stats/__snapshots__/index.spec.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`Stats should render Stats 1`] = `
+exports[`Stats index should render Stats 1`] = `
From 7954bf83caae3a54bd55d3f17117734e22af872c Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Wed, 14 Nov 2018 10:45:43 -0300
Subject: [PATCH 07/30] Update tests for stepOne, stepTwo, stepThree
---
src/components/StepThree/index.js | 14 +-
src/components/StepTwo/index.js | 14 +-
test/components/StepOne/index.spec.js | 16 +-
.../StepThreeFormDutchAuction.spec.js | 195 +++-
.../StepThreeFormDutchAuction.spec.js.snap | 960 +++++++++++++++++-
test/components/StepThree/index.spec.js | 54 +
test/components/StepTwo/StepTwoForm.spec.js | 10 +
.../__snapshots__/StepTwoForm.spec.js.snap | 6 +-
test/components/StepTwo/index.spec.js | 92 +-
9 files changed, 1323 insertions(+), 38 deletions(-)
diff --git a/src/components/StepThree/index.js b/src/components/StepThree/index.js
index 6c1d43a1b..9d62ffc85 100644
--- a/src/components/StepThree/index.js
+++ b/src/components/StepThree/index.js
@@ -34,7 +34,10 @@ export class StepThree extends Component {
reload: false,
initialTiers: [],
burnExcess: 'no',
- gasTypeSelected: {}
+ gasTypeSelected: {},
+ backButtonTriggered: false, //Testing purposes
+ nextButtonTriggered: false, //Testing purposes
+ goBackEnabledTriggered: false //Testing purposes
}
componentDidMount() {
@@ -90,6 +93,9 @@ export class StepThree extends Component {
goNextStep = () => {
try {
+ this.setState({
+ nextButtonTriggered: true
+ })
navigateTo({
history: this.props.history,
location: 'stepFour',
@@ -102,6 +108,9 @@ export class StepThree extends Component {
goBack = () => {
try {
+ this.setState({
+ backButtonTriggered: true
+ })
goBack({
history: this.props.history,
location: '/stepTwo'
@@ -114,6 +123,9 @@ export class StepThree extends Component {
goBackEnabled = () => {
let goBackEnabled = false
try {
+ this.setState({
+ goBackEnabledTriggered: true
+ })
goBackEnabled = goBackMustBeEnabled({ history: this.props.history })
logger.log(`Go back is enabled ${goBackEnabled}`)
} catch (err) {
diff --git a/src/components/StepTwo/index.js b/src/components/StepTwo/index.js
index 65989c8b4..c3f29777c 100644
--- a/src/components/StepTwo/index.js
+++ b/src/components/StepTwo/index.js
@@ -20,7 +20,10 @@ export class StepTwo extends Component {
state = {
loading: false,
tokenValues: {},
- reload: false
+ reload: false,
+ backButtonTriggered: false, //Testing purposes
+ nextButtonTriggered: false, //Testing purposes
+ goBackEnabledTriggered: false //Testing purposes
}
async componentDidMount() {
@@ -51,6 +54,9 @@ export class StepTwo extends Component {
goNextStep = () => {
try {
+ this.setState({
+ nextButtonTriggered: true
+ })
navigateTo({
history: this.props.history,
location: 'stepThree',
@@ -63,6 +69,9 @@ export class StepTwo extends Component {
goBack = () => {
try {
+ this.setState({
+ backButtonTriggered: true
+ })
goBack({
history: this.props.history,
location: '/stepOne'
@@ -75,6 +84,9 @@ export class StepTwo extends Component {
goBackEnabled = () => {
let goBackEnabled = false
try {
+ this.setState({
+ goBackEnabledTriggered: true
+ })
goBackEnabled = goBackMustBeEnabled({ history: this.props.history })
logger.log(`Go back is enabled ${goBackEnabled}`)
} catch (err) {
diff --git a/test/components/StepOne/index.spec.js b/test/components/StepOne/index.spec.js
index c792c0337..1af944a68 100644
--- a/test/components/StepOne/index.spec.js
+++ b/test/components/StepOne/index.spec.js
@@ -130,7 +130,9 @@ describe('StepOne', () => {
.instance()
.load()
// Then
- expect(result).toEqual({ strategy: 'white-list-with-cap' })
+ setTimeout(() => {
+ expect(result).toEqual({ strategy: 'white-list-with-cap' })
+ }, 2000)
})
it(`should render StepOne screen and test reload`, async () => {
@@ -141,14 +143,18 @@ describe('StepOne', () => {
const wrapper = mount( )
// When
-
- expect(global.localStorage.reload).toBe(undefined)
- expect(global.localStorage.clearStorage).toBeTruthy()
+ setTimeout(() => {
+ // Then
+ expect(global.localStorage.reload).toBe(undefined)
+ expect(global.localStorage.clearStorage).toBeTruthy()
+ }, 2000)
})
it(`should render StepOne screen and test beforeUnloadSpy`, async () => {
const wrapper = mount( )
window.location.reload()
- expect(global.localStorage.reload).toBe(undefined)
+ setTimeout(() => {
+ expect(global.localStorage.reload).toBe(undefined)
+ }, 2000)
})
})
diff --git a/test/components/StepThree/StepThreeFormDutchAuction.spec.js b/test/components/StepThree/StepThreeFormDutchAuction.spec.js
index 70382c03f..90d196c49 100644
--- a/test/components/StepThree/StepThreeFormDutchAuction.spec.js
+++ b/test/components/StepThree/StepThreeFormDutchAuction.spec.js
@@ -7,7 +7,7 @@ import Adapter from 'enzyme-adapter-react-15'
import { configure, mount } from 'enzyme'
import setFieldTouched from 'final-form-set-field-touched'
import arrayMutators from 'final-form-arrays'
-import { GAS_PRICE } from '../../../src/utils/constants'
+import { CONTRIBUTION_OPTIONS, GAS_PRICE } from '../../../src/utils/constants'
import {
crowdsaleStore,
gasPriceStore,
@@ -15,9 +15,10 @@ import {
reservedTokenStore,
tierStore,
tokenStore
-} from '../../../src/stores/index'
+} from '../../../src/stores'
import MockDate from 'mockdate'
import { weiToGwei } from '../../../src/utils/utils'
+import { ReservedTokensInputBlock } from '../../../src/components/Common/ReservedTokensInputBlock'
configure({ adapter: new Adapter() })
jest.mock('react-dropzone', () => () => Dropzone )
@@ -39,34 +40,176 @@ describe('StepThreeFormDutchAuction', () => {
generalStore.reset()
})
- it(`should render StepThreeFormDutchAuction`, () => {
- // Given
- const component = renderer.create(
+ it(`should render StepThreeFormDutchAuction- test snapshots`, () => {
+ const component = renderer
+ .create(
+
+
+
+ )
+ .toJSON()
+
+ expect(component).toMatchSnapshot()
+ })
+
+ it(`should render StepThreeFormDutchAuction- test snapshot form`, () => {
+ const props = {
+ onSubmit: jest.fn(),
+ decorators: jest.fn(),
+ values: {
+ burnExcess: false,
+ gasPrice: GAS_PRICE.SLOW,
+ tiers: tierStore.tiers.slice(),
+ walletAddress: walletAddress,
+ whitelistEnabled: 'no'
+ },
+ generalStore: generalStore,
+ crowdsaleStore: crowdsaleStore,
+ gasPriceStore: gasPriceStore,
+ reservedTokenStore: reservedTokenStore,
+ tierStore: tierStore,
+ tokenStore: tokenStore,
+ form: { mutators: {} }
+ }
+ const FormComponent = mount(
+
+
+
+ )
+
+ expect(FormComponent).toMatchSnapshot()
+ })
+
+ it(`should render StepThreeFormDutchAuction- test props I`, () => {
+ const props = {
+ onSubmit: jest.fn(),
+ decorators: jest.fn(),
+ values: {
+ burnExcess: false,
+ gasPrice: GAS_PRICE.SLOW,
+ tiers: tierStore.tiers.slice(),
+ walletAddress: walletAddress,
+ whitelistEnabled: 'no'
+ },
+ generalStore: generalStore,
+ crowdsaleStore: crowdsaleStore,
+ gasPriceStore: gasPriceStore,
+ reservedTokenStore: reservedTokenStore,
+ tierStore: tierStore,
+ tokenStore: tokenStore,
+ form: { mutators: {} }
+ }
+ const FormComponent = mount(
-
+
)
- // When
- const tree = component.toJSON()
+ const componentInstance = FormComponent.instance()
+
+ FormComponent.find('input[name="burnExcessRadioButtons"]')
+ .at(0)
+ .simulate('click')
+
+ expect(
+ FormComponent.find('input[name="burnExcessRadioButtons"]')
+ .find(`[value="yes"]`)
+ .props('checked')
+ ).toBeTruthy()
+ })
+
+ it(`should render StepThreeFormDutchAuction- test props II`, () => {
+ const props = {
+ onSubmit: jest.fn(),
+ decorators: jest.fn(),
+ values: {
+ burnExcess: false,
+ gasPrice: GAS_PRICE.SLOW,
+ tiers: tierStore.tiers.slice(),
+ walletAddress: walletAddress,
+ whitelistEnabled: 'no'
+ },
+ generalStore: generalStore,
+ crowdsaleStore: crowdsaleStore,
+ gasPriceStore: gasPriceStore,
+ reservedTokenStore: reservedTokenStore,
+ tierStore: tierStore,
+ tokenStore: tokenStore,
+ form: { mutators: {} }
+ }
+ const FormComponent = mount(
+
+
+
+ )
+
+ const componentInstance = FormComponent.instance()
+
+ FormComponent.find('input[name="burnExcessRadioButtons"]')
+ .at(1)
+ .simulate('click')
+
+ expect(
+ FormComponent.find('input[name="burnExcessRadioButtons"]')
+ .find(`[value="no"]`)
+ .props('checked')
+ ).toBeTruthy()
+ })
+
+
+ it(`should render StepThreeFormDutchAuction- test props III`, () => {
+ const props = {
+ onSubmit: jest.fn(),
+ decorators: jest.fn(),
+ values: {
+ burnExcess: false,
+ gasPrice: GAS_PRICE.SLOW,
+ tiers: tierStore.tiers.slice(),
+ walletAddress: walletAddress,
+ whitelistEnabled: 'no'
+ },
+ generalStore: generalStore,
+ crowdsaleStore: crowdsaleStore,
+ gasPriceStore: gasPriceStore,
+ reservedTokenStore: reservedTokenStore,
+ tierStore: tierStore,
+ tokenStore: tokenStore,
+ form: { mutators: {} }
+ }
+ const FormComponent = mount(
+
+
+
+ )
+
+ const componentInstance = FormComponent.instance()
+
+ FormComponent.find('input[name="burnExcessRadioButtons"]')
+ .at(1)
+ .simulate('change', { target: { value: 'yes' } })
- // Then
- expect(tree).toMatchSnapshot()
+ expect(
+ FormComponent.find('input[name="burnExcessRadioButtons"]')
+ .find(`[value="yes"]`)
+ .props('checked')
+ ).toBeTruthy()
})
})
diff --git a/test/components/StepThree/__snapshots__/StepThreeFormDutchAuction.spec.js.snap b/test/components/StepThree/__snapshots__/StepThreeFormDutchAuction.spec.js.snap
index 95cdc414e..e40ef8ac3 100644
--- a/test/components/StepThree/__snapshots__/StepThreeFormDutchAuction.spec.js.snap
+++ b/test/components/StepThree/__snapshots__/StepThreeFormDutchAuction.spec.js.snap
@@ -1,6 +1,961 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`StepThreeFormDutchAuction should render StepThreeFormDutchAuction 1`] = `
+exports[`StepThreeFormDutchAuction should render StepThreeFormDutchAuction- test snapshot form 1`] = `
+
+
+
+
+
+`;
+
+exports[`StepThreeFormDutchAuction should render StepThreeFormDutchAuction- test snapshots 1`] = `
+`;
diff --git a/test/components/Common/__snapshots__/MinCap.spec.js.snap b/test/components/Common/__snapshots__/MinCap.spec.js.snap
index 91f25f316..456e35adc 100644
--- a/test/components/Common/__snapshots__/MinCap.spec.js.snap
+++ b/test/components/Common/__snapshots__/MinCap.spec.js.snap
@@ -25,6 +25,7 @@ exports[`MinCap should render MinCap component 1`] = `
`;
diff --git a/test/components/Common/__snapshots__/ReservedTokensInputBlock.spec.js.snap b/test/components/Common/__snapshots__/ReservedTokensInputBlock.spec.js.snap
index 9424a9b6a..d73627955 100644
--- a/test/components/Common/__snapshots__/ReservedTokensInputBlock.spec.js.snap
+++ b/test/components/Common/__snapshots__/ReservedTokensInputBlock.spec.js.snap
@@ -100,6 +100,7 @@ exports[`ReservedTokensInputBlock render should render the component for percent
value=""
>
`;
diff --git a/test/components/Common/__snapshots__/TierBlock.spec.js.snap b/test/components/Common/__snapshots__/TierBlock.spec.js.snap
index 2767c9de9..1b5f71aef 100644
--- a/test/components/Common/__snapshots__/TierBlock.spec.js.snap
+++ b/test/components/Common/__snapshots__/TierBlock.spec.js.snap
@@ -30,6 +30,7 @@ exports[`TierBlock should render TierBlock component 1`] = `
1
5
@@ -50,15 +50,18 @@ exports[`WhitelistTable should render WhitelistTable component 1`] = `
0x665772109Eb2dc9F5B7c28F987Ec58949d4Eeb87
1
5
+
+ Â
+
1
5
+
+ Â
+
1
5
+
+ Â
+
diff --git a/test/components/Contribute/ContributeDataList.spec.js b/test/components/Contribute/ContributeDataList.spec.js
index f8993c030..eaa2805f1 100644
--- a/test/components/Contribute/ContributeDataList.spec.js
+++ b/test/components/Contribute/ContributeDataList.spec.js
@@ -13,10 +13,8 @@ describe(`ContributeDataList`, () => {
it(`should contain the current account address, crowdsale address and a copy button`, () => {
const wrapper = mount( )
const dataItems = wrapper.find('.cnt-ContributeDataList_Item')
- const copyButton = wrapper.find('.sw-ButtonCopyToClipboard')
expect(dataItems.length).toBe(2)
- expect(copyButton.length).toBe(1)
})
it(`should contain only one children`, () => {
diff --git a/test/components/Contribute/CountdownTimer.spec.js b/test/components/Contribute/CountdownTimer.spec.js
index 5e6a6f13f..1c491a181 100644
--- a/test/components/Contribute/CountdownTimer.spec.js
+++ b/test/components/Contribute/CountdownTimer.spec.js
@@ -101,46 +101,4 @@ describe('CountdownTimer', () => {
expect(wrapper).toMatchSnapshot()
})
- it(`Should render the component with alternative message`, () => {
- const altMessage = 'Alternative Message'
-
- const wrapper = shallow(
-
- )
- expect(wrapper).toMatchSnapshot()
-
- const altMessageText = wrapper.find('.timer__altMessage').text()
- expect(altMessageText).toBe(altMessage)
- })
-
- it(`Should stop countdown if crowdsale was finalized`, () => {
- const wrapper = shallow(
-
- )
-
- expect(wrapper.find('ReactCountdownClock').props().seconds).toBe(0)
- })
})
diff --git a/test/components/Contribute/__snapshots__/ContributeDataList.spec.js.snap b/test/components/Contribute/__snapshots__/ContributeDataList.spec.js.snap
index 8bb14fc13..022989106 100644
--- a/test/components/Contribute/__snapshots__/ContributeDataList.spec.js.snap
+++ b/test/components/Contribute/__snapshots__/ContributeDataList.spec.js.snap
@@ -15,6 +15,32 @@ exports[`ContributeDataList should render ContributeDataList component 1`] = `
>
0x1237612212322c1237Cc7c8bBC123cE4D0Cb4123
+
+
+
+
+
+
+
+
+ >
+
+
+
+
+
+
+
- Crowdsale Execution ID
+ Proxy Address
diff --git a/test/components/Contribute/__snapshots__/ContributeForm.spec.js.snap b/test/components/Contribute/__snapshots__/ContributeForm.spec.js.snap
index b1a7ba8ff..fd65a46b9 100644
--- a/test/components/Contribute/__snapshots__/ContributeForm.spec.js.snap
+++ b/test/components/Contribute/__snapshots__/ContributeForm.spec.js.snap
@@ -41,7 +41,7 @@ exports[`ContributeForm Should set as disabled the contribute button if isTierSo
dirtySinceLastSubmit={false}
errors={
Object {
- "contribute": "This field is required",
+ "contribute": "You are not allowed",
}
}
focus={[Function]}
@@ -110,7 +110,7 @@ exports[`ContributeForm Should set as disabled the contribute button if isTierSo
dirtySinceLastSubmit={false}
errors={
Object {
- "contribute": "This field is required",
+ "contribute": "You are not allowed",
}
}
focus={[Function]}
@@ -178,7 +178,7 @@ exports[`ContributeForm Should set as disabled the contribute button if isTierSo
web3Available={true}
>
+ >
+
+ tokens
+
+
Contribute
-
- Think twice before contributing to Crowdsales. Tokens will be deposited on a wallet you used to buy tokens.
-
+ >
+
+ tokens
+
+
- Wallet
+ Wallet
Contribute
-
- Think twice before contributing to Crowdsales. Tokens will be deposited on a wallet you used to buy tokens.
-
`;
exports[`ContributeForm should render ContributeForm component and its children 1`] = `
+ >
+
+ tokens
+
+
- Wallet
+ Wallet
Contribute
-
- Think twice before contributing to Crowdsales. Tokens will be deposited on a wallet you used to buy tokens.
-
`;
diff --git a/test/components/Contribute/__snapshots__/CountdownTimer.spec.js.snap b/test/components/Contribute/__snapshots__/CountdownTimer.spec.js.snap
index 7f6801063..d2adcc927 100644
--- a/test/components/Contribute/__snapshots__/CountdownTimer.spec.js.snap
+++ b/test/components/Contribute/__snapshots__/CountdownTimer.spec.js.snap
@@ -53,7 +53,7 @@ exports[`CountdownTimer Should render the component 1`] = `
- 4
+ 04
- 4
+ 04
- 4
+ 04
- 4
+ 04
-
- Crowdsale has ended
-
-
-
-
-`;
-
-exports[`CountdownTimer Should render the component with alternative message 1`] = `
-
-
-
-
-
-
- To start of tier 1 of 2
-
-
- Alternative Message
+ crowdsale has been finalized
diff --git a/test/components/Contribute/__snapshots__/QRPaymentProcess.spec.js.snap b/test/components/Contribute/__snapshots__/QRPaymentProcess.spec.js.snap
index 5e00f1466..ef5e3632b 100644
--- a/test/components/Contribute/__snapshots__/QRPaymentProcess.spec.js.snap
+++ b/test/components/Contribute/__snapshots__/QRPaymentProcess.spec.js.snap
@@ -32,7 +32,26 @@ exports[`QRPaymentProcess should render QRPaymentProcess component 1`] = `
data-clipboard-text="0xcbf4eb5e9743c335631afe21e158bf1bb21b2864"
onClick={[Function]}
type="button"
- />
+ >
+
+
+
+
+
+
+
- Send ethers to the Auth-os
+ Send ethers to the crowdsale
RegistryExec
- smart-contract address with a MethodID:
- 0x55f8650100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004a6f2ae3a00000000000000000000000000000000000000000000000000000000
+ address with a data:
+
+
+
+ 0x55f8650100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004a6f2ae3a00000000000000000000000000000000000000000000000000000000
+
+
+
+
+
+
+
+
+
+
`;
diff --git a/test/components/Contribute/__snapshots__/index.spec.js.snap b/test/components/Contribute/__snapshots__/index.spec.js.snap
index 689238303..c0995cd6c 100644
--- a/test/components/Contribute/__snapshots__/index.spec.js.snap
+++ b/test/components/Contribute/__snapshots__/index.spec.js.snap
@@ -285,7 +285,7 @@ exports[`Contribute should render Contribute component 1`] = `
+ >
+
+ tokens
+
+
+
+ Think twice before contributing to crowdsales. Tokens will be deposited on a wallet you used to buy tokens.
+
+ >
+
+
+
+
+
+
+
Crowdsale Page
@@ -98,21 +98,21 @@ exports[`Crowdsale index should render Crowdsale 1`] = `
className="st-StepContent"
>
Crowdsale Page
+ >
+
+
+
+
+
+
+
{
const crowdsaleStore = new CrowdsaleStore()
+ const web3Store = new Web3Store()
+
+ let wrapper
let crowdsales = []
crowdsales.push(new Crowdsale())
crowdsales.push(new Crowdsale())
@@ -20,46 +25,46 @@ describe('CrowdsaleList ', () => {
crowdsales[1].execID = accounts[1]
crowdsaleStore.setCrowdsales(crowdsales)
- const web3Store = new Web3Store()
- web3Store.web3 = new Web3(new Web3.providers.HttpProvider('https://sokol.poa.network'))
+ beforeEach(() => {
+ web3Store.web3 = new Web3(new Web3.providers.HttpProvider('https://sokol.poa.network'))
+
+ wrapper = mount(
+
+ )
+ })
- const wrapper = mount(
-
- )
it(`should render CrowdsaleList component`, () => {
expect(wrapper).toMatchSnapshot()
})
+
it(`should render correct number of crowdsales`, () => {
+ const wrapper = shallow(
+
+ )
+
expect(
wrapper
.find('[className="sw-FlexTable_Td"]')
.at(0)
.text()
- ).toBe('Address')
+ ).toBe('')
expect(
wrapper
.find('[className="sw-FlexTable_Td"]')
.at(1)
.text()
- ).toBe(crowdsales[0].execID)
+ ).toBe('')
expect(
wrapper
.find('[className="sw-FlexTable_Td"]')
.at(2)
.text()
- ).toBe(crowdsales[1].execID)
+ ).toBe('')
})
it(`button'Continue' should be disabled if nothing selected `, () => {
expect(wrapper.find('[className="button button_disabled"]')).toBeDefined()
})
- it(`button'Continue' should be enabled if crowdsale selected `, () => {
- wrapper
- .find('[className="sw-FlexTable_Td"]')
- .at(1)
- .simulate('click')
- expect(wrapper.find('[className="button button_fill"]')).toBeDefined()
- })
it(`should render if list is empty `, () => {
const crowdsaleStore = new CrowdsaleStore()
const wrapper = mount(
diff --git a/test/components/Common/__snapshots__/CrowdsalesList.spec.js.snap b/test/components/Crowdsales/__snapshots__/CrowdsalesList.spec.js.snap
similarity index 95%
rename from test/components/Common/__snapshots__/CrowdsalesList.spec.js.snap
rename to test/components/Crowdsales/__snapshots__/CrowdsalesList.spec.js.snap
index 7fb819e5b..8f9c7a598 100644
--- a/test/components/Common/__snapshots__/CrowdsalesList.spec.js.snap
+++ b/test/components/Crowdsales/__snapshots__/CrowdsalesList.spec.js.snap
@@ -1181,50 +1181,78 @@ exports[`CrowdsaleList should render CrowdsaleList component 1`] = `
}
}
>
-
+
+
+ Select Address
+
-
-
-
- 0xcCca436070962a1A884b88E8506C2C750E342BEA
-
-
-
+ 0xcCca436070962a1A884b88E8506C2C750E342BEA
+
+
+
+
+
+
+
+
-
- 0x9726cdb82358972b7a17260e7897C8de02d584e6
-
-
-
+
+ 0x9726cdb82358972b7a17260e7897C8de02d584e6
+
+
+
+
+
-
+
+
+ Select Address
+
-
-
-
- 0xcCca436070962a1A884b88E8506C2C750E342BEA
-
-
-
+ 0xcCca436070962a1A884b88E8506C2C750E342BEA
+
+
+
+
+
+
+
+
-
- 0x9726cdb82358972b7a17260e7897C8de02d584e6
-
-
-
+
+ 0x9726cdb82358972b7a17260e7897C8de02d584e6
+
+
+
+
+
-
+
+
+
+
+
+ Crowdsale List
+
+
+
- Address
+
+
+ Manage Crowdsale
+
-
-
-
+
- Continue
-
-
+
+ Crowdsale List
+
+
+
+
+
+
+ Select Address
+
+
+
+
+
+ Continue
+
+
+
+
-
+
diff --git a/test/components/manage/FinalizeCrowdsaleStep.spec.js b/test/components/Manage/FinalizeCrowdsaleStep.spec.js
similarity index 53%
rename from test/components/manage/FinalizeCrowdsaleStep.spec.js
rename to test/components/Manage/FinalizeCrowdsaleStep.spec.js
index 6a00111e8..f2e36f53e 100644
--- a/test/components/manage/FinalizeCrowdsaleStep.spec.js
+++ b/test/components/Manage/FinalizeCrowdsaleStep.spec.js
@@ -1,6 +1,6 @@
import React from 'react'
import { StaticRouter } from 'react-router'
-import { FinalizeCrowdsaleStep } from '../../../src/components/manage/FinalizeCrowdsaleStep'
+import { FinalizeCrowdsaleStep } from '../../../src/components/Manage/FinalizeCrowdsaleStep'
import renderer from 'react-test-renderer'
import Adapter from 'enzyme-adapter-react-15'
import { configure, mount } from 'enzyme'
@@ -41,42 +41,4 @@ describe('FinalizeCrowdsaleStep', () => {
.toJSON()
).toMatchSnapshot()
})
-
- it('should call handleClick', () => {
- const finalizeCrowdsaleStateParams = {
- disabled: false,
- handleClick: jest.fn()
- }
-
- const wrapper = mount(
-
-
-
- )
-
- const button = wrapper.find('Link').at(0)
-
- button.simulate('click')
-
- expect(finalizeCrowdsaleStateParams.handleClick).toHaveBeenCalled()
- })
-
- it('should not call handleClick', () => {
- const finalizeCrowdsaleStateParams = {
- disabled: true,
- handleClick: jest.fn()
- }
-
- const wrapper = mount(
-
-
-
- )
-
- const button = wrapper.find('Link').at(0)
-
- button.simulate('click')
-
- expect(finalizeCrowdsaleStateParams.handleClick).toHaveBeenCalledTimes(0)
- })
})
diff --git a/test/components/manage/ManageForm.spec.js b/test/components/Manage/ManageForm.spec.js
similarity index 99%
rename from test/components/manage/ManageForm.spec.js
rename to test/components/Manage/ManageForm.spec.js
index 79e3ce4a1..5c94c7c1c 100644
--- a/test/components/manage/ManageForm.spec.js
+++ b/test/components/Manage/ManageForm.spec.js
@@ -2,7 +2,7 @@ import React from 'react'
import { BrowserRouter } from 'react-router-dom'
import { Form } from 'react-final-form'
import arrayMutators from 'final-form-arrays'
-import { ManageForm } from '../../../src/components/manage/ManageForm'
+import { ManageForm } from '../../../src/components/Manage/ManageForm'
import Adapter from 'enzyme-adapter-react-15'
import { configure, mount } from 'enzyme'
import MockDate from 'mockdate'
diff --git a/test/components/manage/ManageTierBlock.spec.js b/test/components/Manage/ManageTierBlock.spec.js
similarity index 59%
rename from test/components/manage/ManageTierBlock.spec.js
rename to test/components/Manage/ManageTierBlock.spec.js
index c93e699fd..f41c73076 100644
--- a/test/components/manage/ManageTierBlock.spec.js
+++ b/test/components/Manage/ManageTierBlock.spec.js
@@ -5,10 +5,14 @@ import renderer from 'react-test-renderer'
import Adapter from 'enzyme-adapter-react-15'
import { configure } from 'enzyme'
import MockDate from 'mockdate'
-import { ManageTierBlock } from '../../../src/components/manage/ManageTierBlock'
+import { ManageTierBlock } from '../../../src/components/Manage/ManageTierBlock'
import CrowdsaleStore from '../../../src/stores/CrowdsaleStore'
import TokenStore from '../../../src/stores/TokenStore'
-import { CROWDSALE_STRATEGIES } from '../../../src/utils/constants'
+import TierStore from '../../../src/stores/TierStore'
+import { Provider } from 'mobx-react'
+import { CROWDSALE_STRATEGIES, VALIDATION_TYPES } from '../../../src/utils/constants'
+
+const { VALID } = VALIDATION_TYPES
const DATE = {
TIER_0: {
@@ -23,7 +27,7 @@ const DATE = {
}
}
-const initialTiers = [
+const tiers = [
{
whitelist: [
{ addr: '0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b', min: 1234, max: 50505, stored: true },
@@ -58,18 +62,85 @@ const initialTiers = [
endTime: '2018-04-21T00:00',
updatable: false,
tier: 'Tier 2',
+ whitelistEnabled: 'yes',
supply: '156',
rate: '55',
minCap: '0'
}
]
+const initialTiers = [
+ {
+ whitelist: [
+ { addr: '0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b', min: 1234, max: 50505, stored: true },
+ { addr: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1', min: 1234, max: 50505, stored: true },
+ { addr: '0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d', min: 1234, max: 50505, stored: true },
+ { addr: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0', min: 1234, max: 50505, stored: true }
+ ],
+ startTime: '2018-04-13T16:07',
+ endTime: '2018-04-17T00:00',
+ duration: '1528827423500',
+ updatable: true,
+ tier: 'Tier 1',
+ isWhitelisted: 'yes',
+ supply: '132',
+ rate: '123',
+ index: '0',
+ addresses: {
+ crowdsaleAddress: '0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae'
+ },
+ minCap: '0'
+ },
+ {
+ whitelist: [
+ { addr: '0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e', min: 1234, max: 50505, stored: true },
+ { addr: '0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b', min: 1234, max: 50505, stored: true },
+ { addr: '0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9', min: 1234, max: 50505, stored: true },
+ { addr: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1', min: 1234, max: 50505, stored: true },
+ { addr: '0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC', min: 1234, max: 50505, stored: true },
+ { addr: '0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E', min: 1234, max: 50505, stored: true },
+ { addr: '0xd03ea8624C8C5987235048901fB614fDcA89b117', min: 1234, max: 50505, stored: true },
+ { addr: '0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d', min: 1234, max: 50505, stored: true },
+ { addr: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0', min: 1234, max: 50505, stored: true }
+ ],
+ startTime: '2018-04-17T00:00',
+ endTime: '2018-04-21T00:00',
+ duration: '1528827423500',
+ updatable: false,
+ tier: 'Tier 2',
+ isWhitelisted: 'yes',
+ supply: '156',
+ rate: '55',
+ index: '1',
+ addresses: {
+ crowdsaleAddress: '0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae'
+ },
+ minCap: '0'
+ }
+]
+
+const validations = {
+ tier: VALID,
+ walletAddress: VALID,
+ rate: VALID,
+ supply: VALID,
+ startTime: VALID,
+ endTime: VALID,
+ updatable: VALID
+}
+
configure({ adapter: new Adapter() })
describe('ManageTierBlock', () => {
it('should render the ManageTierBlock component with tiers for Minted Capped Crowdsale', () => {
const crowdsaleStore = new CrowdsaleStore()
const tokenStore = new TokenStore()
+ const tierStore = new TierStore()
+
+ tierStore.addTier(tiers[0], validations)
+ tierStore.addTier(tiers[1], validations)
+
+ const stores = { crowdsaleStore, tokenStore, tierStore }
crowdsaleStore.setProperty('strategy', CROWDSALE_STRATEGIES.MINTED_CAPPED_CROWDSALE)
MockDate.set(DATE.TIER_0.ACTIVE)
@@ -87,15 +158,18 @@ describe('ManageTierBlock', () => {
canEditTiers: false,
aboutTier:
About Tier
,
crowdsaleStore: crowdsaleStore,
- tokenStore: tokenStore
+ tokenStore: tokenStore,
+ tierStore: tierStore
}
expect(
renderer
.create(
-
- } />
-
+
+
+ } />
+
+
)
.toJSON()
).toMatchSnapshot()
diff --git a/test/components/manage/ReservedTokensList.spec.js b/test/components/Manage/ReservedTokensList.spec.js
similarity index 76%
rename from test/components/manage/ReservedTokensList.spec.js
rename to test/components/Manage/ReservedTokensList.spec.js
index 4d25169ae..23a64e50d 100644
--- a/test/components/manage/ReservedTokensList.spec.js
+++ b/test/components/Manage/ReservedTokensList.spec.js
@@ -1,6 +1,6 @@
import React from 'react'
import { StaticRouter } from 'react-router'
-import { ReservedTokensList } from '../../../src/components/manage/ReservedTokensList'
+import { ReservedTokensList } from '../../../src/components/Manage/ReservedTokensList'
import Adapter from 'enzyme-adapter-react-15'
import { configure, mount } from 'enzyme'
import ReservedTokenStore from '../../../src/stores/ReservedTokenStore'
@@ -41,25 +41,6 @@ describe('DistributeTokensStep', () => {
reservedTokenStore.clearAll()
})
- it(`should render reserved token addresses if it's the owner`, () => {
- tokenList.forEach(token => reservedTokenStore.addToken(token))
-
- const distributeTokensStateParams = {
- disabled: false,
- handleClick: jest.fn(),
- reservedTokenStore,
- owner: true
- }
-
- const wrapper = mount(
-
-
-
- )
-
- expect(wrapper.find('.read-only')).toHaveLength(1)
- })
-
it(`should not render reserved token addresses if not the owner`, () => {
tokenList.forEach(token => reservedTokenStore.addToken(token))
diff --git a/test/components/Manage/__snapshots__/FinalizeCrowdsaleStep.spec.js.snap b/test/components/Manage/__snapshots__/FinalizeCrowdsaleStep.spec.js.snap
new file mode 100644
index 000000000..bdf4ff43e
--- /dev/null
+++ b/test/components/Manage/__snapshots__/FinalizeCrowdsaleStep.spec.js.snap
@@ -0,0 +1,41 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`FinalizeCrowdsaleStep should render the component with active button 1`] = `
+
+
+ After finalization, it’s not possible to update tiers or buy tokens. All tokens will be movable and reserved tokens will be issued.
+
+
+ Finalize Crowdsale
+
+
+`;
+
+exports[`FinalizeCrowdsaleStep should render the component with disabled button 1`] = `
+
+
+ After finalization, it’s not possible to update tiers or buy tokens. All tokens will be movable and reserved tokens will be issued.
+
+
+ Finalize Crowdsale
+
+
+`;
diff --git a/test/components/manage/__snapshots__/ManageForm.spec.js.snap b/test/components/Manage/__snapshots__/ManageForm.spec.js.snap
similarity index 77%
rename from test/components/manage/__snapshots__/ManageForm.spec.js.snap
rename to test/components/Manage/__snapshots__/ManageForm.spec.js.snap
index 1d0f3acca..9a559267f 100644
--- a/test/components/manage/__snapshots__/ManageForm.spec.js.snap
+++ b/test/components/Manage/__snapshots__/ManageForm.spec.js.snap
@@ -2038,745 +2038,121 @@ exports[`ManageForm should render the component with tiers 1`] = `
}
>
-
-
-
-
-
-
- (
- ) Settings
-
-
- The most important and exciting part of the crowdsale process. Here you can
- define parameters of your crowdsale campaign.
-
-
-
- Crowdsale page
-
-
-
-
-
-
-
-
-
-
- Wallet Address
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ (
+ )
+
+ Settings
+
+
+
+
+
+
+
+
+
+ Crowdsale Type
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Wallet Address
+
+
+
+
+
+
+
+
+
+
+
- <_class
+
+ <_class
+ __versions={
+ Object {
+ "final-form": "4.6.1",
+ "react-final-form": "3.4.0",
+ }
+ }
+ batch={[Function]}
+ blur={[Function]}
+ canEditTiers={true}
+ change={[Function]}
+ crowdsaleStore={
+ CrowdsaleStore {
+ "crowdsales": Array [],
+ "endTime": undefined,
+ "maximumSellableTokens": undefined,
+ "maximumSellableTokensInWei": undefined,
+ "selected": Object {
+ "initialTiersValues": Array [],
+ "updatable": false,
+ },
+ "strategy": "white-list-with-cap",
+ "supply": undefined,
+ }
+ }
+ decorators={
+ Array [
+ [MockFunction] {
+ "calls": Array [
+ Array [
+ Object {
+ "batch": [Function],
+ "blur": [Function],
+ "change": [Function],
+ "focus": [Function],
+ "getFieldState": [Function],
+ "getRegisteredFields": [Function],
+ "getState": [Function],
+ "initialize": [Function],
+ "isValidationPaused": [Function],
+ "mutators": Object {
+ "insert": [Function],
+ "move": [Function],
+ "pop": [Function],
+ "push": [Function],
+ "remove": [Function],
+ "shift": [Function],
+ "swap": [Function],
+ "unshift": [Function],
+ },
+ "pauseValidation": [Function],
+ "registerField": [Function],
+ "reset": [Function],
+ "resumeValidation": [Function],
+ "setConfig": [Function],
+ "submit": [Function],
+ "subscribe": [Function],
+ },
+ ],
+ ],
+ "results": Array [
+ Object {
+ "isThrow": false,
+ "value": undefined,
+ },
+ ],
+ },
+ ]
+ }
+ dirty={false}
+ dirtySinceLastSubmit={false}
+ errors={
+ Object {
+ "tiers": Array [
+ Object {
+ "minCap": Array [
+ "Decimals should not exceed the amount of decimals specified",
+ ],
+ },
+ Object {
+ "minCap": Array [
+ "Decimals should not exceed the amount of decimals specified",
+ ],
+ },
+ ],
+ }
+ }
+ fields={
+ Object {
+ "active": false,
+ "blur": [Function],
+ "change": [Function],
+ "data": Object {},
+ "dirty": false,
+ "dirtySinceLastSubmit": false,
+ "error": undefined,
+ "focus": [Function],
+ "forEach": [Function],
+ "initial": Array [
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
+ },
+ "duration": "1528827423500",
+ "endTime": "2018-04-17T00:00",
+ "index": "0",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "123",
+ "startTime": "2018-04-13T16:07",
+ "supply": "132",
+ "tier": "Tier 1",
+ "updatable": true,
+ "whitelist": Array [
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
+ },
+ "duration": "1528827423500",
+ "endTime": "2018-04-21T00:00",
+ "index": "1",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "55",
+ "startTime": "2018-04-17T00:00",
+ "supply": "156",
+ "tier": "Tier 2",
+ "updatable": false,
+ "whitelist": Array [
+ Object {
+ "addr": "0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xd03ea8624C8C5987235048901fB614fDcA89b117",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ ],
+ "insert": [Function],
+ "invalid": false,
+ "length": 2,
+ "map": [Function],
+ "move": [Function],
+ "name": "tiers",
+ "pop": [Function],
+ "pristine": true,
+ "push": [Function],
+ "remove": [Function],
+ "shift": [Function],
+ "submitError": undefined,
+ "submitFailed": false,
+ "submitSucceeded": false,
+ "swap": [Function],
+ "touched": false,
+ "unshift": [Function],
+ "valid": true,
+ "value": Array [
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
+ },
+ "duration": "1528827423500",
+ "endTime": "2018-04-17T00:00",
+ "index": "0",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "123",
+ "startTime": "2018-04-13T16:07",
+ "supply": "132",
+ "tier": "Tier 1",
+ "updatable": true,
+ "whitelist": Array [
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
+ },
+ "duration": "1528827423500",
+ "endTime": "2018-04-21T00:00",
+ "index": "1",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "55",
+ "startTime": "2018-04-17T00:00",
+ "supply": "156",
+ "tier": "Tier 2",
+ "updatable": false,
+ "whitelist": Array [
+ Object {
+ "addr": "0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xd03ea8624C8C5987235048901fB614fDcA89b117",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ ],
+ "visited": false,
+ }
+ }
+ focus={[Function]}
+ form={
+ Object {
+ "batch": [Function],
+ "blur": [Function],
+ "change": [Function],
+ "focus": [Function],
+ "getFieldState": [Function],
+ "getRegisteredFields": [Function],
+ "getState": [Function],
+ "initialize": [Function],
+ "isValidationPaused": [Function],
+ "mutators": Object {
+ "insert": [Function],
+ "move": [Function],
+ "pop": [Function],
+ "push": [Function],
+ "remove": [Function],
+ "shift": [Function],
+ "swap": [Function],
+ "unshift": [Function],
+ },
+ "pauseValidation": [Function],
+ "registerField": [Function],
+ "reset": [Function],
+ "resumeValidation": [Function],
+ "setConfig": [Function],
+ "submit": [Function],
+ "subscribe": [Function],
+ }
+ }
+ hasSubmitErrors={false}
+ hasValidationErrors={true}
+ initialValues={
+ Object {
+ "tiers": Array [
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
+ },
+ "duration": "1528827423500",
+ "endTime": "2018-04-17T00:00",
+ "index": "0",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "123",
+ "startTime": "2018-04-13T16:07",
+ "supply": "132",
+ "tier": "Tier 1",
+ "updatable": true,
+ "whitelist": Array [
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
},
- ],
+ "duration": "1528827423500",
+ "endTime": "2018-04-21T00:00",
+ "index": "1",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "55",
+ "startTime": "2018-04-17T00:00",
+ "supply": "156",
+ "tier": "Tier 2",
+ "updatable": false,
+ "whitelist": Array [
+ Object {
+ "addr": "0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xd03ea8624C8C5987235048901fB614fDcA89b117",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ ],
+ }
+ }
+ initialize={[Function]}
+ mutators={
+ Object {
+ "insert": [Function],
+ "move": [Function],
+ "pop": [Function],
+ "push": [Function],
+ "remove": [Function],
+ "shift": [Function],
+ "swap": [Function],
+ "unshift": [Function],
+ }
+ }
+ reset={[Function]}
+ submitFailed={false}
+ submitSucceeded={false}
+ tokenStore={
+ TokenStore {
+ "decimals": undefined,
+ "name": undefined,
+ "reservedTokensInput": Object {},
+ "supply": 0,
+ "ticker": undefined,
+ "validToken": Object {
+ "decimals": "EMPTY",
+ "name": "EMPTY",
+ "ticker": "EMPTY",
},
- ],
+ }
}
- }
- visited={
- Object {
- "tiers": false,
- "tiers[0].endTime": false,
- "tiers[0].minCap": false,
- "tiers[0].rate": false,
- "tiers[0].startTime": false,
- "tiers[0].supply": false,
- "tiers[1].endTime": false,
- "tiers[1].minCap": false,
- "tiers[1].rate": false,
- "tiers[1].startTime": false,
- "tiers[1].supply": false,
+ touched={
+ Object {
+ "tiers": false,
+ "tiers[0].endTime": false,
+ "tiers[0].minCap": false,
+ "tiers[0].rate": false,
+ "tiers[0].startTime": false,
+ "tiers[0].supply": false,
+ "tiers[1].endTime": false,
+ "tiers[1].minCap": false,
+ "tiers[1].rate": false,
+ "tiers[1].startTime": false,
+ "tiers[1].supply": false,
+ }
}
- }
- >
-
+ valid={false}
+ validating={false}
+ values={
+ Object {
+ "tiers": Array [
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
+ },
+ "duration": "1528827423500",
+ "endTime": "2018-04-17T00:00",
+ "index": "0",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "123",
+ "startTime": "2018-04-13T16:07",
+ "supply": "132",
+ "tier": "Tier 1",
+ "updatable": true,
+ "whitelist": Array [
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ Object {
+ "addresses": Object {
+ "crowdsaleAddress": "0x42a7b7dd785cd69714a189dffb3fd7d7174edc9ece837694ce50f7078f7c31ae",
+ },
+ "duration": "1528827423500",
+ "endTime": "2018-04-21T00:00",
+ "index": "1",
+ "isWhitelisted": "yes",
+ "minCap": "0",
+ "rate": "55",
+ "startTime": "2018-04-17T00:00",
+ "supply": "156",
+ "tier": "Tier 2",
+ "updatable": false,
+ "whitelist": Array [
+ Object {
+ "addr": "0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xd03ea8624C8C5987235048901fB614fDcA89b117",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ Object {
+ "addr": "0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0",
+ "max": 50505,
+ "min": 1234,
+ "stored": true,
+ },
+ ],
+ },
+ ],
+ }
+ }
+ visited={
+ Object {
+ "tiers": false,
+ "tiers[0].endTime": false,
+ "tiers[0].minCap": false,
+ "tiers[0].rate": false,
+ "tiers[0].startTime": false,
+ "tiers[0].supply": false,
+ "tiers[1].endTime": false,
+ "tiers[1].minCap": false,
+ "tiers[1].rate": false,
+ "tiers[1].startTime": false,
+ "tiers[1].supply": false,
+ }
+ }
+ >
+
+ Tier Name:
+ Tier 1
+
-
-
-
-
-
- Tier setup name
-
-
-
-
-
-
-
-
-
-
-
+
+ Tier Name:
+ Tier 2
+
-
-
-
-
-
- Tier setup name
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+ />
-
- Save
-
+
+ Save
+
+
diff --git a/test/components/Manage/__snapshots__/ManageTierBlock.spec.js.snap b/test/components/Manage/__snapshots__/ManageTierBlock.spec.js.snap
new file mode 100644
index 000000000..8d3095b55
--- /dev/null
+++ b/test/components/Manage/__snapshots__/ManageTierBlock.spec.js.snap
@@ -0,0 +1,839 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`ManageTierBlock should render the ManageTierBlock component with tiers for Dutch Auction Crowdsale 1`] = `
+
+
+
+ Tier Name:
+ Tier 1
+
+
+
+
+
+
+ Start Time
+
+
+
+ Date and time when the tier starts. Can't be in the past from the current moment.
+
+
+
+
+
+
+
+
+
+
+ End Time
+
+
+
+ Date and time when the tier ends. Can be only in the future.
+
+
+
+
+
+
+
+
+
+
+ Rate
+
+
+
+ Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
+
+
+
+
+
+
+
+
+
+
+ Supply
+
+
+
+ How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
+
+
+
+
+
+
+
+
+
+
+ Contributor min cap
+
+
+
+
+
+
+
+
+
+ Tier Name:
+ Tier 2
+
+
+
+
+
+
+ Start Time
+
+
+
+ Date and time when the tier starts. Can't be in the past from the current moment.
+
+
+
+
+
+
+
+
+
+
+ End Time
+
+
+
+ Date and time when the tier ends. Can be only in the future.
+
+
+
+
+
+
+
+
+
+
+ Rate
+
+
+
+ Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
+
+
+
+
+
+
+
+
+
+
+ Supply
+
+
+
+ How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
+
+
+
+
+
+
+
+
+
+
+ Contributor min cap
+
+
+
+
+
+
+
+
+`;
+
+exports[`ManageTierBlock should render the ManageTierBlock component with tiers for Minted Capped Crowdsale 1`] = `
+
+
+
+ Tier Name:
+ Tier 1
+
+
+
+
+
+
+ Start Time
+
+
+
+ Date and time when the tier starts. Can't be in the past from the current moment.
+
+
+
+
+
+
+
+
+
+
+ End Time
+
+
+
+ Date and time when the tier ends. Can be only in the future.
+
+
+
+
+
+
+
+
+
+
+ Rate
+
+
+
+ Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
+
+
+
+
+
+
+
+
+
+
+ Supply
+
+
+
+ How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
+
+
+
+
+
+
+
+
+
+
+ Contributor min cap
+
+
+
+
+
+
+
+
+
+ Tier Name:
+ Tier 2
+
+
+
+
+
+
+ Start Time
+
+
+
+ Date and time when the tier starts. Can't be in the past from the current moment.
+
+
+
+
+
+
+
+
+
+
+ End Time
+
+
+
+ Date and time when the tier ends. Can be only in the future.
+
+
+
+
+
+
+
+
+
+
+ Rate
+
+
+
+ Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
+
+
+
+
+
+
+
+
+
+
+ Supply
+
+
+
+ How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
+
+
+
+
+
+
+
+
+
+
+ Contributor min cap
+
+
+
+
+
+
+
+
+`;
diff --git a/test/components/Manage/__snapshots__/index.spec.js.snap b/test/components/Manage/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..da7f98f3f
--- /dev/null
+++ b/test/components/Manage/__snapshots__/index.spec.js.snap
@@ -0,0 +1,145 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Manage index should render Manage 1`] = `
+
+
+
+
+
+
+
+
+
+ Crowdsale List
+
+
+
+
+
+ Manage Crowdsale
+
+
+
+
+
+
+
+
+
+ Manage Crowdsale
+
+
+
+
+
+
+
+ After finalization, it’s not possible to update tiers or buy tokens. All tokens will be movable and reserved tokens will be issued.
+
+
+ Finalize Crowdsale
+
+
+
+
+ Back
+
+
+
+
+
+
+`;
diff --git a/test/components/manage/index.spec.js b/test/components/Manage/index.spec.js
similarity index 94%
rename from test/components/manage/index.spec.js
rename to test/components/Manage/index.spec.js
index 429c1af57..5574c6c5d 100644
--- a/test/components/manage/index.spec.js
+++ b/test/components/Manage/index.spec.js
@@ -4,7 +4,7 @@ import { Provider } from 'mobx-react'
import { configure } from 'enzyme'
import renderer from 'react-test-renderer'
import { MemoryRouter } from 'react-router'
-import { Manage } from '../../../src/components/manage/index'
+import { Manage } from '../../../src/components/Manage/index'
import {
crowdsaleStore,
web3Store,
diff --git a/test/components/manage/utils.spec.js b/test/components/Manage/utils.spec.js
similarity index 97%
rename from test/components/manage/utils.spec.js
rename to test/components/Manage/utils.spec.js
index d9e4b7bee..1b7d7083d 100644
--- a/test/components/manage/utils.spec.js
+++ b/test/components/Manage/utils.spec.js
@@ -1,4 +1,4 @@
-import { getFieldsToUpdate } from '../../../src/components/manage/utils'
+import { getFieldsToUpdate } from '../../../src/components/Manage/utils'
describe('getFieldsToUpdate', () => {
it('should include only fields that have changed', () => {
diff --git a/test/components/Stats/__snapshots__/index.spec.js.snap b/test/components/Stats/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..1a6bd7c63
--- /dev/null
+++ b/test/components/Stats/__snapshots__/index.spec.js.snap
@@ -0,0 +1,481 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Stats index should render Stats 1`] = `
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+ Total crowdsales amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Total amount of eth raised
+
+
+
+
+
+
+
+
+ 0
+
+
+ Total contributors amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max amount of eth raised in one crowdsale
+
+
+
+
+
+
+ Minted capped crowdsales statistics
+
+
+
+
+
+
+ 0
+
+
+ Crowdsales amount
+
+
+
+
+ 0
+
+
+ Total amount of eth raised
+
+
+
+
+ 0
+
+
+ Total contributors amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Ongoing crowdsales amount
+
+
+
+
+ 0
+
+
+ Future crowdsales amount
+
+
+
+
+ 0
+
+
+ Past crowdsales amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max amount of eth raised in one crowdsale
+
+
+
+
+ 0
+
+
+ % of finalized crowdsales from ended
+
+
+
+
+ 0
+
+
+ % of crowdsales with multiple tiers
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max tiers amount in one crowdsale
+
+
+
+
+
+
+ Dutch auction crowdsales statistics
+
+
+
+
+
+
+ 0
+
+
+ Crowdsales amount
+
+
+
+
+ 0
+
+
+ Total amount of eth raised
+
+
+
+
+ 0
+
+
+ Total contributors amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Ongoing crowdsales amount
+
+
+
+
+ 0
+
+
+ Future crowdsales amount
+
+
+
+
+ 0
+
+
+ Past crowdsales amount
+
+
+
+
+
+
+
+
+ 0
+
+
+ Max amount of eth raised in one crowdsale
+
+
+
+
+ 0
+
+
+ % of finalized crowdsales from ended
+
+
+
+
+
+
+
+
+`;
diff --git a/test/components/stats/index.spec.js b/test/components/Stats/index.spec.js
similarity index 92%
rename from test/components/stats/index.spec.js
rename to test/components/Stats/index.spec.js
index 8ca30e263..c496d05fa 100644
--- a/test/components/stats/index.spec.js
+++ b/test/components/Stats/index.spec.js
@@ -4,7 +4,7 @@ import { Provider } from 'mobx-react'
import { configure } from 'enzyme'
import renderer from 'react-test-renderer'
import { MemoryRouter } from 'react-router'
-import { Stats } from '../../../src/components/stats/index'
+import { Stats } from '../../../src/components/Stats/index'
import { web3Store, statsStore } from '../../../src/stores'
configure({ adapter: new Adapter() })
diff --git a/test/components/StepFour/__snapshots__/CrowdsaleSetupBlockDutchAuction.spec.js.snap b/test/components/StepFour/__snapshots__/CrowdsaleSetupBlockDutchAuction.spec.js.snap
index 1a0895257..ae0f01a24 100644
--- a/test/components/StepFour/__snapshots__/CrowdsaleSetupBlockDutchAuction.spec.js.snap
+++ b/test/components/StepFour/__snapshots__/CrowdsaleSetupBlockDutchAuction.spec.js.snap
@@ -6,26 +6,26 @@ exports[`CrowdsalSetupBlockDutchAuction should render the component 1`] = `
>
diff --git a/test/components/StepOne/__snapshots__/StrategyItem.spec.js.snap b/test/components/StepOne/__snapshots__/StrategyItem.spec.js.snap
index 71da650e0..4f34f7ff7 100644
--- a/test/components/StepOne/__snapshots__/StrategyItem.spec.js.snap
+++ b/test/components/StepOne/__snapshots__/StrategyItem.spec.js.snap
@@ -1,36 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`StrategyItem should render screen with mount without throwing an error 1`] = `
-
-`;
+exports[`StrategyItem should render screen with mount without throwing an error 1`] = `null`;
-exports[`StrategyItem should render screen with render without throwing an error 1`] = `
-
-`;
+exports[`StrategyItem should render screen with render without throwing an error 1`] = `null`;
-exports[`StrategyItem should render screen with shallow without throwing an error 1`] = `
-
-`;
+exports[`StrategyItem should render screen with shallow without throwing an error 1`] = `null`;
diff --git a/test/components/StepOne/__snapshots__/index.spec.js.snap b/test/components/StepOne/__snapshots__/index.spec.js.snap
index e1cb6aa45..07e7def80 100644
--- a/test/components/StepOne/__snapshots__/index.spec.js.snap
+++ b/test/components/StepOne/__snapshots__/index.spec.js.snap
@@ -125,11 +125,11 @@ exports[`StepOne should render StepOne screen 1`] = `
className="sw-RadioItems"
>
Whitelist with Cap
Modern crowdsale strategy with multiple tiers, whitelists, and limits. Recommended for every crowdsale.
Dutch Auction
An auction with descending price.
diff --git a/test/components/StepThree/__snapshots__/GasPriceInput.spec.js.snap b/test/components/StepThree/__snapshots__/GasPriceInput.spec.js.snap
index f74dda8f4..91bb2ac8e 100644
--- a/test/components/StepThree/__snapshots__/GasPriceInput.spec.js.snap
+++ b/test/components/StepThree/__snapshots__/GasPriceInput.spec.js.snap
@@ -422,6 +422,7 @@ exports[`GasPriceInput should render GasPriceInput component with custom gasType
value={0.1}
>
{
- it('should render the component', () => {
- const aboutCrowdsaleParams = {
- name: 'MyToken',
- ticker: 'MTK',
- execID: '0x461451505864e9dfe45bac39478a4ed689d74a737c0c3308cb0c8607ca0c14bd',
- networkID: '12648430'
- }
-
- expect(
- renderer
- .create(
-
-
-
- )
- .toJSON()
- ).toMatchSnapshot()
- })
-})
diff --git a/test/components/manage/ReadOnlyWhitelistAddresses.spec.js b/test/components/manage/ReadOnlyWhitelistAddresses.spec.js
deleted file mode 100644
index 11f358d13..000000000
--- a/test/components/manage/ReadOnlyWhitelistAddresses.spec.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import React from 'react'
-import { ReadOnlyWhitelistAddresses } from '../../../src/components/manage/ReadOnlyWhitelistAddresses'
-import renderer from 'react-test-renderer'
-import Adapter from 'enzyme-adapter-react-15'
-import { configure, mount } from 'enzyme'
-
-const noAddressMessage = 'no addresses loaded'
-
-const whitelistsAddresses = [
- { addr: '0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e', min: 1234, max: 50505, stored: true },
- { addr: '0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b', min: 1234, max: 50505, stored: true },
- { addr: '0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9', min: 1234, max: 50505, stored: true },
- { addr: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1', min: 1234, max: 50505, stored: true },
- { addr: '0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC', min: 1234, max: 50505, stored: true },
- { addr: '0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E', min: 1234, max: 50505, stored: true },
- { addr: '0xd03ea8624C8C5987235048901fB614fDcA89b117', min: 1234, max: 50505, stored: true },
- { addr: '0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d', min: 1234, max: 50505, stored: true },
- { addr: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0', min: 1234, max: 50505, stored: true }
-]
-
-configure({ adapter: new Adapter() })
-
-describe('ManageForm', () => {
- it('should render the whitelist addresses', () => {
- expect(
- renderer.create( ).toJSON()
- ).toMatchSnapshot()
- })
-
- it(`should render "${noAddressMessage}" message if no whitelist available`, () => {
- const wrapper = mount( )
-
- const message = wrapper.find('span')
-
- expect(message.text()).toBe(noAddressMessage)
- })
-})
diff --git a/test/components/manage/__snapshots__/FinalizeCrowdsaleStep.spec.js.snap b/test/components/manage/__snapshots__/FinalizeCrowdsaleStep.spec.js.snap
deleted file mode 100644
index b67d6f798..000000000
--- a/test/components/manage/__snapshots__/FinalizeCrowdsaleStep.spec.js.snap
+++ /dev/null
@@ -1,73 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`FinalizeCrowdsaleStep should render the component with active button 1`] = `
-
-
-
- !
-
-
- Finalize Crowdsale
-
-
- Finalize - Finalization is the last step of the crowdsale. You can make it only after the end of the last tier. After finalization, it's not possible to update tiers, buy tokens. All tokens will be movable, reserved tokens will be issued.
-
-
-
- Finalize Crowdsale
-
-
-
-
-`;
-
-exports[`FinalizeCrowdsaleStep should render the component with disabled button 1`] = `
-
-
-
- !
-
-
- Finalize Crowdsale
-
-
- Finalize - Finalization is the last step of the crowdsale. You can make it only after the end of the last tier. After finalization, it's not possible to update tiers, buy tokens. All tokens will be movable, reserved tokens will be issued.
-
-
-
- Finalize Crowdsale
-
-
-
-
-`;
diff --git a/test/components/manage/__snapshots__/ManageTierBlock.spec.js.snap b/test/components/manage/__snapshots__/ManageTierBlock.spec.js.snap
deleted file mode 100644
index 7343aaca5..000000000
--- a/test/components/manage/__snapshots__/ManageTierBlock.spec.js.snap
+++ /dev/null
@@ -1,1061 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`ManageTierBlock should render the ManageTierBlock component with tiers for Dutch Auction Crowdsale 1`] = `
-
-
-
-
-
-
-
-
- Tier setup name
-
-
-
-
-
-
-
-
-
-
- Start Time
-
-
-
- Date and time when the tier starts. Can't be in the past from the current moment.
-
-
-
-
-
-
-
-
- End Time
-
-
-
- Date and time when the tier ends. Can be only in the future.
-
-
-
-
-
-
-
-
-
-
- Rate
-
-
-
- Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
-
-
-
-
-
-
-
-
- Supply
-
-
-
- How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
-
-
-
-
-
-
-
-
-
-
- Contributor min cap
-
-
-
-
-
-
-
-
-
-
-
-
- 0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Tier setup name
-
-
-
-
-
-
-
-
-
-
- Start Time
-
-
-
- Date and time when the tier starts. Can't be in the past from the current moment.
-
-
-
-
-
-
-
-
- End Time
-
-
-
- Date and time when the tier ends. Can be only in the future.
-
-
-
-
-
-
-
-
-
-
- Rate
-
-
-
- Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
-
-
-
-
-
-
-
-
- Supply
-
-
-
- How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
-
-
-
-
-
-
-
-
-
-
- Contributor min cap
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`ManageTierBlock should render the ManageTierBlock component with tiers for Minted Capped Crowdsale 1`] = `
-
-
-
-
-
-
-
-
- Tier setup name
-
-
-
-
-
-
-
-
-
-
- Start Time
-
-
-
- Date and time when the tier starts. Can't be in the past from the current moment.
-
-
-
-
-
-
-
-
- End Time
-
-
-
- Date and time when the tier ends. Can be only in the future.
-
-
-
-
-
-
-
-
-
-
- Rate
-
-
-
- Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
-
-
-
-
-
-
-
-
- Supply
-
-
-
- How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
-
-
-
-
-
-
-
-
-
-
- Contributor min cap
-
-
-
-
-
-
-
-
-
-
-
-
- 0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Tier setup name
-
-
-
-
-
-
-
-
-
-
- Start Time
-
-
-
- Date and time when the tier starts. Can't be in the past from the current moment.
-
-
-
-
-
-
-
-
- End Time
-
-
-
- Date and time when the tier ends. Can be only in the future.
-
-
-
-
-
-
-
-
-
-
- Rate
-
-
-
- Exchange rate Ethereum to Tokens. If it's 100, then for 1 Ether you can buy 100 tokens
-
-
-
-
-
-
-
-
- Supply
-
-
-
- How many tokens will be sold on this tier. Cap of crowdsale equals to sum of supply of all tiers
-
-
-
-
-
-
-
-
-
-
- Contributor min cap
-
-
-
-
-
-
-
-
-
-`;
diff --git a/test/components/manage/__snapshots__/index.spec.js.snap b/test/components/manage/__snapshots__/index.spec.js.snap
deleted file mode 100644
index 5e05df061..000000000
--- a/test/components/manage/__snapshots__/index.spec.js.snap
+++ /dev/null
@@ -1,67 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Manage index should render Manage 1`] = `
-
-
-
-
- !
-
-
- Finalize Crowdsale
-
-
- Finalize - Finalization is the last step of the crowdsale. You can make it only after the end of the last tier. After finalization, it's not possible to update tiers, buy tokens. All tokens will be movable, reserved tokens will be issued.
-
-
-
- Finalize Crowdsale
-
-
-
-
-
-
-`;
diff --git a/test/components/stats/__snapshots__/index.spec.js.snap b/test/components/stats/__snapshots__/index.spec.js.snap
deleted file mode 100644
index a57e5e1b0..000000000
--- a/test/components/stats/__snapshots__/index.spec.js.snap
+++ /dev/null
@@ -1,457 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Stats index should render Stats 1`] = `
-
-
- Token Wizard statistics
-
-
-
-
-
-
- 0
-
-
- Total crowdsales amount
-
-
-
-
-
-
-
-
- 0
-
-
- Total amount of eth raised
-
-
-
-
-
-
-
-
- 0
-
-
- Total contributors amount
-
-
-
-
-
-
-
-
- 0
-
-
- Max amount of eth raised in one crowdsale
-
-
-
-
-
-
- Minted capped crowdsales statistics
-
-
-
-
-
-
- 0
-
-
- Crowdsales amount
-
-
-
-
- 0
-
-
- Total amount of eth raised
-
-
-
-
- 0
-
-
- Total contributors amount
-
-
-
-
-
-
-
-
- 0
-
-
- Ongoing crowdsales amount
-
-
-
-
- 0
-
-
- Future crowdsales amount
-
-
-
-
- 0
-
-
- Past crowdsales amount
-
-
-
-
-
-
-
-
- 0
-
-
- Max amount of eth raised in one crowdsale
-
-
-
-
- 0
-
-
- % of finalized crowdsales from ended
-
-
-
-
- 0
-
-
- % of crowdsales with multiple tiers
-
-
-
-
-
-
-
-
- 0
-
-
- Max tiers amount in one crowdsale
-
-
-
-
-
-
- Dutch auction crowdsales statistics
-
-
-
-
-
-
- 0
-
-
- Crowdsales amount
-
-
-
-
- 0
-
-
- Total amount of eth raised
-
-
-
-
- 0
-
-
- Total contributors amount
-
-
-
-
-
-
-
-
- 0
-
-
- Ongoing crowdsales amount
-
-
-
-
- 0
-
-
- Future crowdsales amount
-
-
-
-
- 0
-
-
- Past crowdsales amount
-
-
-
-
-
-
-
-
- 0
-
-
- Max amount of eth raised in one crowdsale
-
-
-
-
- 0
-
-
- % of finalized crowdsales from ended
-
-
-
-
-
-
-
-`;
diff --git a/test/stores/CrowdsalePageStore.spec.js b/test/stores/CrowdsalePageStore.spec.js
index 9973f8241..89e2bbcfb 100644
--- a/test/stores/CrowdsalePageStore.spec.js
+++ b/test/stores/CrowdsalePageStore.spec.js
@@ -8,6 +8,7 @@ describe('CrowdsalePageStore', () => {
let sortedTiers
let ticks
let crowdsalePageStore
+
beforeEach(() => {
crowdsalePageStore = new CrowdsalePageStore()
MockDate.set(currentTime)
@@ -25,12 +26,12 @@ describe('CrowdsalePageStore', () => {
{ startDate: 1523563542000, endDate: 1552421142000 }
]
ticks = [
- { type: 'start', time: 1520885142000, order: 1 },
- { type: 'end', time: 1520888742000, order: 1 },
- { type: 'end', time: 1520971542000, order: 2 },
- { type: 'start', time: 1521489942000, order: 3 },
- { type: 'end', time: 1523563542000, order: 3 },
- { type: 'end', time: 1552421142000, order: 4 }
+ { type: 'start', startDate: 1520885142000, order: 1 },
+ { type: 'end', startDate: 1520888742000, order: 1 },
+ { type: 'end', startDate: 1520971542000, order: 2 },
+ { type: 'start', startDate: 1521489942000, order: 3 },
+ { type: 'end', startDate: 1523563542000, order: 3 },
+ { type: 'end', startDate: 1552421142000, order: 4 }
]
})
@@ -51,29 +52,6 @@ describe('CrowdsalePageStore', () => {
})
})
- it('Should build ticks from tiers collection', () => {
- tiers.forEach(tier => crowdsalePageStore.addTier(tier))
- crowdsalePageStore.ticks.forEach((tick, index) => {
- expect(tick.type).toBe(ticks[index].type)
- expect(tick.time).toBe(ticks[index].time)
- expect(tick.order).toBe(ticks[index].order)
- })
- })
-
- it('Should discard past ticks already closed', () => {
- MockDate.set('2018-03-13T12:00:00')
-
- tiers.forEach(tier => crowdsalePageStore.addTier(tier))
- expect(crowdsalePageStore.ticks.length).toBe(4)
-
- const activeTicks = ticks.slice(2)
- crowdsalePageStore.ticks.forEach((tick, index) => {
- expect(tick.type).toBe(activeTicks[index].type)
- expect(tick.time).toBe(activeTicks[index].time)
- expect(tick.order).toBe(activeTicks[index].order)
- })
- })
-
it('Should mutate ticks collection on extract', () => {
tiers.forEach(tier => crowdsalePageStore.addTier(tier))
@@ -81,13 +59,4 @@ describe('CrowdsalePageStore', () => {
crowdsalePageStore.extractNextTick()
expect(crowdsalePageStore.ticks.length).toBe(5)
})
-
- it('Should return the nearest tick in collection', () => {
- tiers.forEach(tier => crowdsalePageStore.addTier(tier))
-
- const nextTick = crowdsalePageStore.extractNextTick()
- expect(nextTick.type).toBe(ticks[0].type)
- expect(nextTick.time).toBe(ticks[0].time)
- expect(nextTick.order).toBe(ticks[0].order)
- })
})
From 550e72f37b2e112835c3657c340620fbecfdcafd Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Thu, 29 Nov 2018 23:15:30 -0300
Subject: [PATCH 28/30] Update tests
---
.../__snapshots__/AboutCrowdsale.spec.js.snap | 32 ---
.../ReadOnlyWhitelistAddresses.spec.js.snap | 213 ------------------
2 files changed, 245 deletions(-)
delete mode 100644 test/components/manage/__snapshots__/AboutCrowdsale.spec.js.snap
delete mode 100644 test/components/manage/__snapshots__/ReadOnlyWhitelistAddresses.spec.js.snap
diff --git a/test/components/manage/__snapshots__/AboutCrowdsale.spec.js.snap b/test/components/manage/__snapshots__/AboutCrowdsale.spec.js.snap
deleted file mode 100644
index e24d93e0a..000000000
--- a/test/components/manage/__snapshots__/AboutCrowdsale.spec.js.snap
+++ /dev/null
@@ -1,32 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`AboutCrowdsale should render the component 1`] = `
-
-
-
- MyToken
- (
- MTK
- ) Settings
-
-
- The most important and exciting part of the crowdsale process. Here you can
- define parameters of your crowdsale campaign.
-
-
- Crowdsale page
-
-
-`;
diff --git a/test/components/manage/__snapshots__/ReadOnlyWhitelistAddresses.spec.js.snap b/test/components/manage/__snapshots__/ReadOnlyWhitelistAddresses.spec.js.snap
deleted file mode 100644
index f63ed97be..000000000
--- a/test/components/manage/__snapshots__/ReadOnlyWhitelistAddresses.spec.js.snap
+++ /dev/null
@@ -1,213 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`ManageForm should render the whitelist addresses 1`] = `
-
-
-
-
- 0x1dF62f291b2E969fB0849d99D9Ce41e2F137006e
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0x22d491Bde2303f2f43325b2108D26f1eAbA1e32b
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0x3E5e9111Ae8eB78Fe1CC3bb8915d5D461F3Ef9A9
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0x95cED938F7991cd0dFcb48F0a06a40FA1aF46EBC
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xACa94ef8bD5ffEE41947b4585a84BdA5a3d3DA6E
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xd03ea8624C8C5987235048901fB614fDcA89b117
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xE11BA2b4D45Eaed5996Cd0823791E0C93114882d
-
-
- 1234
-
-
- 50505
-
-
-
-
-
-
- 0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0
-
-
- 1234
-
-
- 50505
-
-
-
-
-`;
From 6f61bded2ef26598e1b97d026dd7000ac7bd17f1 Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Fri, 30 Nov 2018 11:31:20 -0300
Subject: [PATCH 29/30] Add toast and toFixed tests
---
src/utils/utils.js | 6 ++++-
test/utils/utils.spec.js | 55 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/src/utils/utils.js b/src/utils/utils.js
index f8ca0672c..b2003cc22 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -86,7 +86,11 @@ export const toast = {
return
}
- this.msg[type](message, options)
+ if (typeof this.msg[type] === 'function') {
+ this.msg[type](message, options)
+ } else {
+ return
+ }
}
}
diff --git a/test/utils/utils.spec.js b/test/utils/utils.spec.js
index 5f6922658..ad4871ed9 100644
--- a/test/utils/utils.spec.js
+++ b/test/utils/utils.spec.js
@@ -8,8 +8,10 @@ import {
validateTier,
navigateTo,
downloadFile,
+ toFixed,
goBackMustBeEnabled,
goBack,
+ toast,
convertLocationToPath,
uniqueElementsBy
} from '../../src/utils/utils'
@@ -355,4 +357,57 @@ describe('Utils', () => {
})
})
})
+
+ describe('toFixed', () => {
+ let testsValues = [
+ { value: '1.123', expected: '1.123' },
+ { value: '1.12', expected: '1.12' },
+ { value: '1.', expected: '1.' },
+ { value: '1', expected: '1' },
+ { value: '.123', expected: '.123' },
+ { value: 0.123, expected: 0.123 },
+ { value: '1e-3', expected: '0.001' },
+ { value: '1e-2', expected: '0.01' },
+ { value: '1.2e-2', expected: '0.012' },
+ { value: '1.e-2', expected: '0.01' },
+ { value: '1.e-22', expected: '0.0000000000000000000001' },
+ { value: '1.23123e2', expected: '1.23123e2' },
+ { value: '123.123e+2', expected: '123.123e+2' },
+ { value: 123.123e2, expected: 12312.3 },
+ { value: '.2e-2', expected: '0.002' },
+ { value: '1', expected: '1' },
+ { value: '123', expected: '123' },
+ { value: '0', expected: '0' },
+ { value: '-123', expected: '-123' },
+ { value: 'abc', expected: 'abc' },
+ { value: 'e', expected: 'e' },
+ { value: '', expected: '' }
+ ]
+ testsValues.forEach(testCase => {
+ it(`Should apply toFixed to ${testCase.value}`, () => {
+ expect(toFixed(testCase.value)).toBe(testCase.expected)
+ })
+ })
+ })
+
+ describe('toast', () => {
+ it(`Should use toast with empty message and return undefined`, () => {
+ expect(toast.showToaster({ message: '' })).toBeUndefined()
+ })
+
+ it(`Should use toast with a message and return undefined`, () => {
+ toast.showToaster({ message: 'heelo' })
+ expect(toast.msg.info).toBeUndefined()
+ })
+
+ it(`Should use toast with a message and return a valid message`, () => {
+ toast.msg = {
+ info: (message, options) => {
+ return message
+ }
+ }
+ toast.showToaster({ message: 'hello' })
+ expect(toast.msg.info()).toBeUndefined()
+ })
+ })
})
From 6e7320054c481a13a3e5212b35c03f40d5ca0f15 Mon Sep 17 00:00:00 2001
From: Mariano Aguero
Date: Fri, 30 Nov 2018 14:51:00 -0300
Subject: [PATCH 30/30] Add more utils tests
---
test/utils/api.spec.js | 11 +++++++++++
test/utils/utils.spec.js | 14 ++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 test/utils/api.spec.js
diff --git a/test/utils/api.spec.js b/test/utils/api.spec.js
new file mode 100644
index 000000000..10a9fbb32
--- /dev/null
+++ b/test/utils/api.spec.js
@@ -0,0 +1,11 @@
+import { gasPriceValues } from '../../src/utils/api'
+
+// jest.mock('../../src/utils/api')
+
+describe('Api spec', function() {
+ it(`Should get gas price values`, () => {
+ const gasPricevaluesPromised = async () => await gasPriceValues()
+
+ expect(typeof gasPricevaluesPromised()).toBe('object')
+ })
+})
diff --git a/test/utils/utils.spec.js b/test/utils/utils.spec.js
index ad4871ed9..f1017be71 100644
--- a/test/utils/utils.spec.js
+++ b/test/utils/utils.spec.js
@@ -13,6 +13,11 @@ import {
goBack,
toast,
convertLocationToPath,
+ convertDateToLocalTimezoneInUnix,
+ convertDateToUTCTimezoneToDisplay,
+ getContractBySourceType,
+ getSourceTypeTitle,
+ updateProxyContractInfo,
uniqueElementsBy
} from '../../src/utils/utils'
@@ -410,4 +415,13 @@ describe('Utils', () => {
expect(toast.msg.info()).toBeUndefined()
})
})
+
+ describe('convertDateToLocalTimezoneInUnix', function() {
+ let testsValues = [{ value: '2018-10-10' }, { value: '2018-01-01' }]
+ testsValues.forEach(testCase => {
+ it(`Should apply toFixed to ${testCase.value}`, () => {
+ expect(typeof convertDateToLocalTimezoneInUnix(testCase.value)).toBe('number')
+ })
+ })
+ })
})