Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Increment test coverage #1241

Open
wants to merge 32 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
887a484
Add utils test
Nov 12, 2018
8d5daa3
Refactor fectch file
Nov 12, 2018
1b1ed23
Remove functions
Nov 12, 2018
e1a2230
Update tests for StepOne and Home components
Nov 12, 2018
73f8f0c
Add tests for crowdsale, manage and stats
Nov 13, 2018
d98eb0b
Update tests snapshots
Nov 13, 2018
7954bf8
Update tests for stepOne, stepTwo, stepThree
Nov 14, 2018
66aac32
Update tests for stepThree and refactoring of utils files
Nov 14, 2018
c7d17b7
Add deployment store test
Nov 15, 2018
0586baa
Add getStepExecutionOrder test
Nov 23, 2018
c05a5a6
Add tests for resetTx
Nov 23, 2018
59da06d
Add tests for setDeploymentStepStatus
Nov 23, 2018
0b9ab69
Add cancelDeploy test
Nov 25, 2018
b76c4b2
Add web3Provider test
Nov 26, 2018
be5f0cc
Add BorderedSection test
Nov 26, 2018
dbf2dab
Add ConfigurationBlock test
Nov 26, 2018
d4a5e05
Add CrowdsaleSetupBlockDutchAuction test
Nov 26, 2018
fceb6f9
Add CrowdsaleSetupBlockWhitelistWithCap test
Nov 26, 2018
193dd61
Add TierSetupDutchAuction TierSetupWhitelistWithCap test
Nov 26, 2018
d64ab6d
Add snapshots tests for stepFour
Nov 26, 2018
0c33185
Indent
Nov 26, 2018
91d5bf3
Add tests for tokenSetupBlock
Nov 26, 2018
7812314
Add utils tests for steFour
Nov 26, 2018
a26b67f
Add PreventRefresh test
Nov 26, 2018
d7b83c0
Add Web3Provider test
Nov 26, 2018
53af831
Update Web3Provider test
Nov 26, 2018
630d98d
Merge branch 'integration/#1082-new-design' into 1214-test-stepfour-a…
Nov 29, 2018
b7c3913
Merge branch '2.0' into 1214-test-stepfour-after-facelifting
Nov 29, 2018
60cf753
Update tests
Nov 30, 2018
550e72f
Update tests
Nov 30, 2018
6f61bde
Add toast and toFixed tests
Nov 30, 2018
6e73200
Add more utils tests
Nov 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/Home/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
14 changes: 5 additions & 9 deletions src/components/StepOne/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,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 => {
Expand Down
14 changes: 13 additions & 1 deletion src/components/StepThree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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() {
Expand Down Expand Up @@ -99,6 +102,9 @@ export class StepThree extends Component {

goNextStep = () => {
try {
this.setState({
nextButtonTriggered: true
})
navigateTo({
history: this.props.history,
location: 'stepFour',
Expand All @@ -111,6 +117,9 @@ export class StepThree extends Component {

goBack = () => {
try {
this.setState({
backButtonTriggered: true
})
goBack({
history: this.props.history,
location: '/stepTwo'
Expand All @@ -123,6 +132,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) {
Expand Down
14 changes: 13 additions & 1 deletion src/components/StepTwo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ const logger = logdown('TW:stepTwo:index')
export class StepTwo extends Component {
state = {
tokenValues: {},
reload: false
reload: false,
backButtonTriggered: false, //Testing purposes
nextButtonTriggered: false, //Testing purposes
goBackEnabledTriggered: false //Testing purposes
}

async componentDidMount() {
Expand Down Expand Up @@ -51,6 +54,9 @@ export class StepTwo extends Component {

goNextStep = () => {
try {
this.setState({
nextButtonTriggered: true
})
navigateTo({
history: this.props.history,
location: 'stepThree',
Expand All @@ -63,6 +69,9 @@ export class StepTwo extends Component {

goBack = () => {
try {
this.setState({
backButtonTriggered: true
})
goBack({
history: this.props.history,
location: '/stepOne'
Expand All @@ -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) {
Expand Down
38 changes: 38 additions & 0 deletions src/stores/StatsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ class StatsStore {
@observable totalInvolvedContributorsAmount
@observable maxTiersAmount
@observable maxEthRaised
@observable totalContributorsAmount
@observable mintedCappedEthRaised
@observable dutchAuctionEthRaised
@observable mintedCappedCrowdsales
@observable dutchAuctionCrowdsales
@observable mintedCappedContributorsAmount
@observable dutchAuctionContributorsAmount
@observable mintedCappedPercentageOfFinalized
@observable dutchAuctionPercentageOfFinalized
@observable mintedCappedPercentageOfMultiTiers
@observable mintedCappedMaxTiersAmount
@observable mintedCappedMaxEthRaised
@observable dutchAuctionMaxEthRaised
@observable mintedCappedOngoingCrowdsales
@observable mintedCappedFutureCrowdsales
@observable mintedCappedPastCrowdsales
@observable dutchAuctionOngoingCrowdsales
@observable dutchAuctionFutureCrowdsales
@observable dutchAuctionPastCrowdsales

constructor() {
this.totalEthRaised = 0
Expand All @@ -21,6 +40,25 @@ class StatsStore {
this.totalInvolvedContributorsAmount = 0
this.maxTiersAmount = 0
this.maxEthRaised = 0
this.totalContributorsAmount = 0
this.mintedCappedEthRaised = 0
this.dutchAuctionEthRaised = 0
this.mintedCappedCrowdsales = 0
this.dutchAuctionCrowdsales = 0
this.mintedCappedContributorsAmount = 0
this.dutchAuctionContributorsAmount = 0
this.mintedCappedPercentageOfFinalized = 0
this.dutchAuctionPercentageOfFinalized = 0
this.mintedCappedPercentageOfMultiTiers = 0
this.mintedCappedMaxTiersAmount = 0
this.mintedCappedMaxEthRaised = 0
this.dutchAuctionMaxEthRaised = 0
this.mintedCappedOngoingCrowdsales = 0
this.mintedCappedFutureCrowdsales = 0
this.mintedCappedPastCrowdsales = 0
this.dutchAuctionOngoingCrowdsales = 0
this.dutchAuctionFutureCrowdsales = 0
this.dutchAuctionPastCrowdsales = 0
}

@action
Expand Down
8 changes: 4 additions & 4 deletions src/stores/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions src/utils/__mocks__/alerts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const cancellingIncompleteDeploy = () => {
return new Promise((resolve, reject) => {
return resolve({
value: true
})
})
}
Loading