Browse Source

feature(channels): add basic test for channels reducer

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
28fff8101d
  1. 106
      test/reducers/__snapshots__/channels.spec.js.snap
  2. 48
      test/reducers/channels.spec.js

106
test/reducers/__snapshots__/channels.spec.js.snap

@ -1,5 +1,111 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`reducers channelsReducer should correctly setChannel 1`] = `
Object {
"channel": "channel",
"channelForm": Object {
"isOpen": false,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [],
"channelsLoading": false,
"openingChannel": false,
"pendingChannels": Object {
"pending_closing_channels": Array [],
"pending_force_closing_channels": Array [],
"pending_open_channels": Array [],
"total_limbo_balance": "",
},
}
`;
exports[`reducers channelsReducer should correctly setChannelForm 1`] = `
Object {
"channel": null,
"channelForm": Object {
"isOpen": true,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [],
"channelsLoading": false,
"openingChannel": false,
"pendingChannels": Object {
"pending_closing_channels": Array [],
"pending_force_closing_channels": Array [],
"pending_open_channels": Array [],
"total_limbo_balance": "",
},
}
`;
exports[`reducers channelsReducer should correctly setChannelForm 2`] = `
Object {
"channel": null,
"channelForm": Object {
"isOpen": false,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [],
"channelsLoading": true,
"openingChannel": false,
"pendingChannels": Object {
"pending_closing_channels": Array [],
"pending_force_closing_channels": Array [],
"pending_open_channels": Array [],
"total_limbo_balance": "",
},
}
`;
exports[`reducers channelsReducer should correctly setChannelForm 3`] = `
Object {
"channel": null,
"channelForm": Object {
"isOpen": false,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [
1,
2,
],
"channelsLoading": false,
"openingChannel": false,
"pendingChannels": Array [
3,
4,
],
}
`;
exports[`reducers channelsReducer should correctly setChannelForm 4`] = `
Object {
"channel": null,
"channelForm": Object {
"isOpen": false,
"local_amt": "",
"node_key": "",
"push_amt": "",
},
"channels": Array [],
"channelsLoading": false,
"openingChannel": true,
"pendingChannels": Object {
"pending_closing_channels": Array [],
"pending_force_closing_channels": Array [],
"pending_open_channels": Array [],
"total_limbo_balance": "",
},
}
`;
exports[`reducers channelsReducer should handle initial state 1`] = ` exports[`reducers channelsReducer should handle initial state 1`] = `
Object { Object {
"channel": null, "channel": null,

48
test/reducers/channels.spec.js

@ -13,5 +13,53 @@ describe('reducers', () => {
it('should handle initial state', () => { it('should handle initial state', () => {
expect(channelsReducer(undefined, {})).toMatchSnapshot() expect(channelsReducer(undefined, {})).toMatchSnapshot()
}) })
it('should have SET_CHANNEL_FORM', () => {
expect(SET_CHANNEL_FORM).toEqual('SET_CHANNEL_FORM')
})
it('should have SET_CHANNEL', () => {
expect(SET_CHANNEL).toEqual('SET_CHANNEL')
})
it('should have GET_CHANNELS', () => {
expect(GET_CHANNELS).toEqual('GET_CHANNELS')
})
it('should have RECEIVE_CHANNELS', () => {
expect(RECEIVE_CHANNELS).toEqual('RECEIVE_CHANNELS')
})
it('should have OPENING_CHANNEL', () => {
expect(OPENING_CHANNEL).toEqual('OPENING_CHANNEL')
})
it('should have OPENING_SUCCESSFUL', () => {
expect(OPENING_SUCCESSFUL).toEqual('OPENING_SUCCESSFUL')
})
it('should have OPENING_FAILURE', () => {
expect(OPENING_FAILURE).toEqual('OPENING_FAILURE')
})
it('should correctly setChannel', () => {
expect(channelsReducer(undefined, { type: SET_CHANNEL, channel: 'channel' })).toMatchSnapshot()
})
it('should correctly setChannelForm', () => {
expect(channelsReducer(undefined, { type: SET_CHANNEL_FORM, form: { isOpen: true } })).toMatchSnapshot()
})
it('should correctly setChannelForm', () => {
expect(channelsReducer(undefined, { type: GET_CHANNELS })).toMatchSnapshot()
})
it('should correctly setChannelForm', () => {
expect(channelsReducer(undefined, { type: RECEIVE_CHANNELS, channels: [1, 2], pendingChannels: [3, 4] })).toMatchSnapshot()
})
it('should correctly setChannelForm', () => {
expect(channelsReducer(undefined, { type: OPENING_CHANNEL })).toMatchSnapshot()
})
}) })
}) })
Loading…
Cancel
Save