Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanmino committed Jan 21, 2019
1 parent 084fd48 commit 74a92e0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ proxyquire('../send-to-row.container.js', {
'./send-to-row.selectors.js': {
getToDropdownOpen: (s) => `mockToDropdownOpen:${s}`,
sendToIsInError: (s) => `mockInError:${s}`,
getTokens: (s) => `mockTokens:${s}`,
},
'../../../../actions': actionSpies,
'../../../../ducks/send.duck': duckActionSpies,
Expand All @@ -48,6 +49,7 @@ describe('send-to-row container', () => {
to: 'mockTo:mockState',
toAccounts: 'mockToAccounts:mockState',
toDropdownOpen: 'mockToDropdownOpen:mockState',
tokens: 'mockTo:mockState',
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'assert'
import {
getToDropdownOpen,
getTokens,
sendToIsInError,
} from '../send-to-row.selectors.js'

Expand Down Expand Up @@ -42,6 +43,16 @@ describe('send-to-row selectors', () => {

assert.equal(sendToIsInError(state), false)
})

it('should return false if send.errors.to is falsy', () => {
const state = {
metamask: {
tokens: [],
},
}

assert.equal(getTokens(state), [])
})
})

})
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import sinon from 'sinon'
import {
REQUIRED_ERROR,
INVALID_RECIPIENT_ADDRESS_ERROR,
KNOWN_RECIPIENT_ADDRESS_ERROR,
} from '../../../send.constants'

const stubs = {
Expand Down Expand Up @@ -52,6 +53,18 @@ describe('send-to-row utils', () => {
to: 'someExplicitError',
})
})

it('should return a known address recipient if to is truthy but part of state tokens', () => {
assert.deepEqual(getToErrorObject('0xabc123', null, false, ['0xabc123']), {
to: KNOWN_RECIPIENT_ADDRESS_ERROR,
})
})

it('should return a known address recipient if to is truthy but part of contract metadata', () => {
assert.deepEqual(getToErrorObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359'), {
to: KNOWN_RECIPIENT_ADDRESS_ERROR,
})
})
})

})

0 comments on commit 74a92e0

Please sign in to comment.