Skip to content

Commit c5eb3f5

Browse files
committed
narrows tests: Fix type error missed by Flow
`initialState` wasn't a valid NarrowsState, which is Immutable.Map<string, $ReadOnlyArray<number>> For what that type-checking problem is and how we plan to avoid it in the future, see the next commit. While we're here, make the test data a bit more interesting than the intended value, by having the action act on a narrow that's different from the one already in the state.
1 parent fc2dab7 commit c5eb3f5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/chat/__tests__/narrowsReducer-test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,23 +320,24 @@ describe('narrowsReducer', () => {
320320
// MESSAGE_FETCH_START applies the identity function to the
321321
// state (i.e., it doesn't do anything to it). Reversing that
322322
// effect is also done with the identity function.
323-
const initialState = Immutable.Map({
324-
[HOME_NARROW_STR]: {
325-
older: true,
326-
newer: true,
327-
},
328-
});
323+
324+
const narrow1 = pm1to1NarrowFromUser(eg.otherUser);
325+
const narrow2 = pm1to1NarrowFromUser(eg.thirdUser);
326+
327+
// Include some other narrow to test that the reducer doesn't go mess
328+
// something up there.
329+
const initialState = Immutable.Map([[keyFromNarrow(narrow1), [1, 2]]]);
329330

330331
const messageFetchStartAction = deepFreeze({
331332
...eg.action.message_fetch_start,
332-
narrow: HOME_NARROW,
333+
narrow: narrow2,
333334
});
334335

335336
const state1 = narrowsReducer(initialState, messageFetchStartAction);
336337

337338
const messageFetchErrorAction = deepFreeze({
338339
type: MESSAGE_FETCH_ERROR,
339-
narrow: HOME_NARROW,
340+
narrow: narrow2,
340341
error: new Error(),
341342
});
342343

0 commit comments

Comments
 (0)