Skip to content

Commit

Permalink
fetchActions tests [nfc]: Bring out initial state definition for reuse.
Browse files Browse the repository at this point in the history
Also assign some one-off messages to variables, for reuse.

We'll be adding tests that use these soon.
  • Loading branch information
chrisbobbe committed Aug 7, 2020
1 parent 0fab721 commit 6b60f80
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/message/__tests__/fetchActions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ describe('fetchActions', () => {
});

describe('fetchMessages', () => {
test('message fetch success action is dispatched after successful fetch', async () => {
const message1 = eg.streamMessage({ id: 1 });
const message1 = eg.streamMessage({ id: 1 });
const message2 = eg.streamMessage({ id: 2 });
const message3 = eg.streamMessage({ id: 3 });

const store = mockStore<GlobalState, Action>(
eg.reduxState({
...navStateWithNarrow(HOME_NARROW),
accounts: [eg.makeAccount()],
narrows: {
[streamNarrowStr]: [message1.id],
},
}),
);
const baseState = eg.reduxState({
...navStateWithNarrow(HOME_NARROW),
accounts: [eg.makeAccount()],
narrows: {
[streamNarrowStr]: [message1.id],
},
});

test('message fetch success action is dispatched after successful fetch', async () => {
const store = mockStore<GlobalState, Action>(baseState);

const response = {
messages: [message1, eg.streamMessage({ id: 2 }), eg.streamMessage({ id: 3 })],
messages: [message1, message2, message3],
result: 'success',
};
fetch.mockResponseSuccess(JSON.stringify(response));
Expand Down

0 comments on commit 6b60f80

Please sign in to comment.