-
Notifications
You must be signed in to change notification settings - Fork 504
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(add test for kvstore buysell selectors)
- Loading branch information
1 parent
bb45df5
commit 04714e0
Showing
1 changed file
with
131 additions
and
0 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
packages/blockchain-wallet-v4/src/redux/kvStore/buySell/selectors.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import Remote from '../../../remote' | ||
import * as selectors from './selectors' | ||
|
||
describe('kvstore root selectors', () => { | ||
const coinifyTrades = [ | ||
{ | ||
id: 42, | ||
state: 'awaiting_transfer_in', | ||
confirmed: false, | ||
is_buy: false | ||
} | ||
] | ||
|
||
const sfoxTrades = [ | ||
{ | ||
id: 'my sfox trade id', | ||
state: 'processing', | ||
tx_hash: 'my sfox tx hash', | ||
confirmed: false, | ||
is_buy: false | ||
} | ||
] | ||
|
||
const buySellMetadata = { | ||
value: { | ||
coinify: { | ||
offline_token: 'my coinify token', | ||
trades: coinifyTrades, | ||
user: 42 | ||
}, | ||
sfox: { | ||
account_token: 'my sfox account token', | ||
trades: sfoxTrades, | ||
user: 'my user id' | ||
} | ||
} | ||
} | ||
|
||
const successState = { | ||
kvStorePath: { | ||
buySell: Remote.Success(buySellMetadata) | ||
} | ||
} | ||
|
||
it('getMetadata should return success of metadata', () => { | ||
const expectedResult = Remote.Success(buySellMetadata) | ||
expect(selectors.getMetadata(successState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getSfoxTrades should return success of metadata sfox trades in success state', () => { | ||
const expectedResult = Remote.Success(sfoxTrades) | ||
expect(selectors.getSfoxTrades(successState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getSfoxUser should return success of metadata sfox user in success state', () => { | ||
const expectedResult = Remote.Success('my user id') | ||
expect(selectors.getSfoxUser(successState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getCoinifyTrades should return success of metadata coinify trades in success state', () => { | ||
const expectedResult = Remote.Success(coinifyTrades) | ||
expect(selectors.getCoinifyTrades(successState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getBuySellTxHashMatch should return buy_sell in success state if hash exists', () => { | ||
const expectedResult = 'buy-sell' | ||
expect(selectors.getBuySellTxHashMatch(successState, 'my sfox tx hash')).toEqual(expectedResult) | ||
}) | ||
|
||
const loadingState = { | ||
kvStorePath: { | ||
buySell: Remote.Loading | ||
} | ||
} | ||
|
||
it('getMetadata should return loading of metadata', () => { | ||
const expectedResult = Remote.Loading | ||
expect(selectors.getMetadata(loadingState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getSfoxTrades should return loading of metadata sfox trades in loading state', () => { | ||
const expectedResult = Remote.Loading | ||
expect(selectors.getSfoxTrades(loadingState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getSfoxUser should return loading of metadata sfox user in loading state', () => { | ||
const expectedResult = Remote.Loading | ||
expect(selectors.getSfoxUser(loadingState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getCoinifyTrades should return loading of metadata coinify trades in loading state', () => { | ||
const expectedResult = Remote.Loading | ||
expect(selectors.getCoinifyTrades(loadingState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getBuySellTxHashMatch should return false in loading state', () => { | ||
const expectedResult = false | ||
expect(selectors.getBuySellTxHashMatch(loadingState, 'my sfox tx hash')).toEqual(expectedResult) | ||
}) | ||
|
||
const failureState = { | ||
kvStorePath: { | ||
buySell: Remote.Failure('Metadata buysell selectors failure') | ||
} | ||
} | ||
|
||
it('getMetadata should return failure of metadata', () => { | ||
const expectedResult = Remote.Failure('Metadata buysell selectors failure') | ||
expect(selectors.getMetadata(failureState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getSfoxTrades should return failure of metadata sfox trades in failure state', () => { | ||
const expectedResult = Remote.Failure('Metadata buysell selectors failure') | ||
expect(selectors.getSfoxTrades(failureState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getSfoxUser should return failure of metadata sfox user in failure state', () => { | ||
const expectedResult = Remote.Failure('Metadata buysell selectors failure') | ||
expect(selectors.getSfoxUser(failureState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getCoinifyTrades should return failure of metadata coinify trades in failure state', () => { | ||
const expectedResult = Remote.Failure('Metadata buysell selectors failure') | ||
expect(selectors.getCoinifyTrades(failureState)).toEqual(expectedResult) | ||
}) | ||
|
||
it('getBuySellTxHashMatch should return false in failure state', () => { | ||
const expectedResult = false | ||
expect(selectors.getBuySellTxHashMatch(failureState, 'my sfox tx hash')).toEqual(expectedResult) | ||
}) | ||
}) |