Skip to content

Commit 06d2f84

Browse files
committed
fetching tests [nfc]: Avoid misleading initialState name
1 parent 40934bf commit 06d2f84

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/chat/__tests__/fetchingReducer-test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('fetchingReducer', () => {
2525

2626
describe('MESSAGE_FETCH_START', () => {
2727
test('if messages are fetched before or after the corresponding flag is set', () => {
28-
const initialState = deepFreeze({
28+
const prevState = deepFreeze({
2929
[HOME_NARROW_STR]: { older: false, newer: false },
3030
});
3131

@@ -40,13 +40,13 @@ describe('fetchingReducer', () => {
4040
[HOME_NARROW_STR]: { older: true, newer: true },
4141
};
4242

43-
const newState = fetchingReducer(initialState, action);
43+
const newState = fetchingReducer(prevState, action);
4444

4545
expect(newState).toEqual(expectedState);
4646
});
4747

4848
test('if key for narrow does not exist, it is created and corresponding flags are set', () => {
49-
const initialState = deepFreeze({
49+
const prevState = deepFreeze({
5050
[HOME_NARROW_STR]: { older: false, newer: false },
5151
});
5252

@@ -63,13 +63,13 @@ describe('fetchingReducer', () => {
6363
[keyFromNarrow(narrow)]: { older: true, newer: false },
6464
};
6565

66-
const newState = fetchingReducer(initialState, action);
66+
const newState = fetchingReducer(prevState, action);
6767

6868
expect(newState).toEqual(expectedState);
6969
});
7070

7171
test('if fetching for a search narrow, ignore', () => {
72-
const initialState = deepFreeze({
72+
const prevState = deepFreeze({
7373
[HOME_NARROW_STR]: {
7474
older: false,
7575
newer: false,
@@ -81,24 +81,24 @@ describe('fetchingReducer', () => {
8181
narrow: SEARCH_NARROW('some query'),
8282
});
8383

84-
const newState = fetchingReducer(initialState, action);
84+
const newState = fetchingReducer(prevState, action);
8585

86-
expect(newState).toEqual(initialState);
86+
expect(newState).toEqual(prevState);
8787
});
8888
});
8989

9090
describe('MESSAGE_FETCH_ERROR', () => {
9191
test('reverses the effect of MESSAGE_FETCH_START as much as possible', () => {
9292
// As of the addition of this test, that means setting
9393
// DEFAULT_FETCHING as the key.
94-
const initialState = deepFreeze({});
94+
const state0 = deepFreeze({});
9595

9696
const messageFetchStartAction = deepFreeze({
9797
...eg.action.message_fetch_start,
9898
narrow: HOME_NARROW,
9999
});
100100

101-
const state1 = fetchingReducer(initialState, messageFetchStartAction);
101+
const state1 = fetchingReducer(state0, messageFetchStartAction);
102102

103103
const messageFetchErrorAction = deepFreeze({
104104
type: MESSAGE_FETCH_ERROR,
@@ -118,7 +118,7 @@ describe('fetchingReducer', () => {
118118

119119
describe('MESSAGE_FETCH_COMPLETE', () => {
120120
test('sets corresponding fetching flags to false, if messages are received before or after', () => {
121-
const initialState = deepFreeze({
121+
const prevState = deepFreeze({
122122
[HOME_NARROW_STR]: { older: true, newer: true },
123123
});
124124

@@ -133,14 +133,14 @@ describe('fetchingReducer', () => {
133133
[HOME_NARROW_STR]: { older: false, newer: true },
134134
};
135135

136-
const newState = fetchingReducer(initialState, action);
136+
const newState = fetchingReducer(prevState, action);
137137

138138
expect(newState).toEqual(expectedState);
139139
});
140140
});
141141

142142
test('if fetched messages are from a search narrow, ignore them', () => {
143-
const initialState = deepFreeze({
143+
const prevState = deepFreeze({
144144
[HOME_NARROW_STR]: { older: true, newer: true },
145145
});
146146

@@ -149,8 +149,8 @@ describe('fetchingReducer', () => {
149149
narrow: SEARCH_NARROW('some query'),
150150
});
151151

152-
const newState = fetchingReducer(initialState, action);
152+
const newState = fetchingReducer(prevState, action);
153153

154-
expect(newState).toEqual(initialState);
154+
expect(newState).toEqual(prevState);
155155
});
156156
});

0 commit comments

Comments
 (0)