Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
wensihao123 committed May 30, 2019
1 parent 88eaea2 commit b23fccd
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
99 changes: 99 additions & 0 deletions src/ts/actions/__snapshots__/stakeActions.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,33 @@ Array [
]
`;

exports[`actions refreshAdmin 1`] = `
Array [
Object {
"type": "stakeStates",
"value": Object {
"canStake": false,
"canUnstake": false,
"lockMinTimeInSecond": 0,
"maxStakePerOracle": 0,
"minStakeAmt": 0,
"totalAwardsToDistribute": 0,
},
},
Object {
"type": "stakeAddresses",
"value": Object {
"operator": "0x415DE7Edfe2c9bBF8449e33Ff88c9be698483CC0",
"priceFeedList": Array [
"0x0022BFd6AFaD3408A1714fa8F9371ad5Ce8A0F1a",
"0x002002812b42601Ae5026344F0395E68527bb0F8",
"0x00476E55e02673B0E4D2B474071014D5a366Ed4E",
],
},
},
]
`;

exports[`actions subscribe 1`] = `
Array [
Object {
Expand Down Expand Up @@ -319,6 +346,78 @@ Array [
]
`;

exports[`actions subscribeAdmin 1`] = `
Array [
Object {
"id": 0,
"type": "stakeSubscription",
},
Object {
"id": 123,
"type": "stakeSubscription",
},
Object {
"type": "stakeStates",
"value": Object {
"canStake": false,
"canUnstake": false,
"lockMinTimeInSecond": 0,
"maxStakePerOracle": 0,
"minStakeAmt": 0,
"totalAwardsToDistribute": 0,
},
},
Object {
"type": "stakeAddresses",
"value": Object {
"operator": "0x415DE7Edfe2c9bBF8449e33Ff88c9be698483CC0",
"priceFeedList": Array [
"0x0022BFd6AFaD3408A1714fa8F9371ad5Ce8A0F1a",
"0x002002812b42601Ae5026344F0395E68527bb0F8",
"0x00476E55e02673B0E4D2B474071014D5a366Ed4E",
],
},
},
]
`;

exports[`actions subscribeAdmin 2`] = `30000`;

exports[`actions subscribeAdmin 3`] = `
Array [
Object {
"id": 0,
"type": "stakeSubscription",
},
Object {
"id": 123,
"type": "stakeSubscription",
},
Object {
"type": "stakeStates",
"value": Object {
"canStake": false,
"canUnstake": false,
"lockMinTimeInSecond": 0,
"maxStakePerOracle": 0,
"minStakeAmt": 0,
"totalAwardsToDistribute": 0,
},
},
Object {
"type": "stakeAddresses",
"value": Object {
"operator": "0x415DE7Edfe2c9bBF8449e33Ff88c9be698483CC0",
"priceFeedList": Array [
"0x0022BFd6AFaD3408A1714fa8F9371ad5Ce8A0F1a",
"0x002002812b42601Ae5026344F0395E68527bb0F8",
"0x00476E55e02673B0E4D2B474071014D5a366Ed4E",
],
},
},
]
`;

exports[`actions subscriptionUpdate 1`] = `
Object {
"id": 123,
Expand Down
35 changes: 35 additions & 0 deletions src/ts/actions/stakeActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,41 @@ describe('actions', () => {
expect(store.getActions()).toMatchSnapshot();
expect((window.setInterval as jest.Mock).mock.calls[0][1]).toMatchSnapshot();

(window.setInterval as jest.Mock).mock.calls[0][0]();
expect(store.getActions()).toMatchSnapshot();
resolve();
}, 0)
);
});
test('refreshAdmin', () => {
util.getDates = jest.fn(() => ['1970-01-15']);
const store: any = stakeStore({
stake: {
states: {},
addresses: []
},
web3: { account: '0x415DE7Edfe2c9bBF8449e33Ff88c9be698483CC0' }
});

store.dispatch(stakeActions.refreshAdmin());
return new Promise(resolve =>
setTimeout(() => {
expect(store.getActions()).toMatchSnapshot();
resolve();
}, 0)
);
});
test('subscribeAdmin', () => {
window.setInterval = jest.fn(() => 123);
const store: any = stakeStore({
web3: { account: '0x415DE7Edfe2c9bBF8449e33Ff88c9be698483CC0' }
});
store.dispatch(stakeActions.subscribeAdmin());
return new Promise(resolve =>
setTimeout(() => {
expect(store.getActions()).toMatchSnapshot();
expect((window.setInterval as jest.Mock).mock.calls[0][1]).toMatchSnapshot();

(window.setInterval as jest.Mock).mock.calls[0][0]();
expect(store.getActions()).toMatchSnapshot();
resolve();
Expand Down

0 comments on commit b23fccd

Please sign in to comment.