Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
feat(Condition): add testnet condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Thore3 committed Oct 20, 2017
1 parent 3eac98b commit c2b1077
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/conditions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ exports.isInCountryBlacklist = (feature) => Condition.of((env) => {

return passedWithReason(passed, 'in_country_blacklist')
})

exports.isUsingTestnet = Condition.of((env) => {
let options = env.get(Env.WALLET_OPTIONS)
return passedWithReason(options.network === 'testnet', 'using_testnet')
})
16 changes: 16 additions & 0 deletions tests/conditions/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ describe('conditions', () => {
})
})

describe('.isUsingTestnet', () => {
it('should pass when the user is using testnet', () => {
let env = makeEnv(null, { network: 'testnet' }, null)
let result = conditions.isUsingTestnet.test(env)
expect(result.passed).toEqual(true)
expect(result.reason).toEqual(['using_testnet'])
})

it('should fail when the user is using mainnet', () => {
let env = makeEnv(null, { network: 'bitcoin' }, null)
let result = conditions.isUsingTestnet.test(env)
expect(result.passed).toEqual(false)
expect(result.reason).toEqual(['not_using_testnet'])
})
})

describe('composite', () => {
let makeAccountInfo = (countryCodeGuess, stateCodeGuess) =>
({ countryCodeGuess, stateCodeGuess })
Expand Down

1 comment on commit c2b1077

@Artic2019
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тест

Please sign in to comment.