Skip to content

Commit 1c1ab3e

Browse files
committed
narrow tests [nfc]: Rename tests to avoid overloading "muted"
These are a bit hard to follow already, and would get more so with the introduction of unmuted topics in muted streams. Also rename a local variable to be hopefully a bit clearer about what it does.
1 parent ed301e7 commit 1c1ab3e

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

src/chat/__tests__/narrowsSelectors-test.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ describe('getShownMessagesForNarrow', () => {
9595
const message = eg.streamMessage();
9696
const subscription = eg.subscription;
9797
const mutedSubscription = { ...subscription, in_home_view: false };
98-
const mutes = makeMuteState([[stream, message.subject]]);
98+
const muteTopic = makeMuteState([[stream, message.subject]]);
9999

100100
const makeStateGeneral = (message, narrow, extra) =>
101101
eg.reduxStatePlus({
@@ -110,31 +110,31 @@ describe('getShownMessagesForNarrow', () => {
110110
const makeState = extra => makeStateGeneral(message, narrow, extra);
111111
const shown = state => shownGeneral(state, narrow);
112112

113-
test('private messages are never muted', () => {
113+
test('private message shown', () => {
114114
expect(shown(makeStateGeneral(eg.pmMessage(), narrow))).toEqual(true);
115115
});
116116

117-
test('message in a stream is not muted if stream and topic not muted', () => {
117+
test('stream message shown in base case', () => {
118118
expect(shown(makeState())).toEqual(true);
119119
});
120120

121-
test('message in a stream is muted if stream is not in subscriptions', () => {
121+
test('stream message hidden if not subscribed to stream', () => {
122122
expect(shown(makeState({ subscriptions: [] }))).toEqual(false);
123123
});
124124

125-
test('message in a stream is muted if the stream is muted', () => {
125+
test('stream message hidden if stream muted', () => {
126126
expect(shown(makeState({ subscriptions: [mutedSubscription] }))).toEqual(false);
127127
});
128128

129-
test('message in a stream is muted if the topic is muted and topic matches', () => {
130-
expect(shown(makeState({ mute: mutes }))).toEqual(false);
129+
test('stream message hidden if topic muted', () => {
130+
expect(shown(makeState({ mute: muteTopic }))).toEqual(false);
131131
});
132132

133-
test('@-mention message is never muted', () => {
133+
test('@-mention message is always shown', () => {
134134
const flags = { ...eg.plusReduxState.flags, mentioned: { [message.id]: true } };
135135
expect(shown(makeState({ flags, subscriptions: [] }))).toEqual(true);
136136
expect(shown(makeState({ flags, subscriptions: [mutedSubscription] }))).toEqual(true);
137-
expect(shown(makeState({ flags, mute: mutes }))).toEqual(true);
137+
expect(shown(makeState({ flags, mute: muteTopic }))).toEqual(true);
138138
});
139139
});
140140

@@ -143,23 +143,23 @@ describe('getShownMessagesForNarrow', () => {
143143
const makeState = extra => makeStateGeneral(message, narrow, extra);
144144
const shown = state => shownGeneral(state, narrow);
145145

146-
test('message not muted even if stream not subscribed', () => {
146+
test('message shown even if not subscribed to stream', () => {
147147
expect(shown(makeState({ subscriptions: [] }))).toEqual(true);
148148
});
149149

150-
test('message not muted even if stream is muted', () => {
150+
test('message shown even if stream muted', () => {
151151
expect(shown(makeState({ subscriptions: [mutedSubscription] }))).toEqual(true);
152152
});
153153

154-
test('message muted if topic is muted', () => {
155-
expect(shown(makeState({ mute: mutes }))).toEqual(false);
154+
test('message hidden if topic muted', () => {
155+
expect(shown(makeState({ mute: muteTopic }))).toEqual(false);
156156
});
157157

158-
test('@-mention message is never muted', () => {
158+
test('@-mention message is always shown', () => {
159159
const flags = { ...eg.plusReduxState.flags, mentioned: { [message.id]: true } };
160160
expect(shown(makeState({ flags, subscriptions: [] }))).toEqual(true);
161161
expect(shown(makeState({ flags, subscriptions: [mutedSubscription] }))).toEqual(true);
162-
expect(shown(makeState({ flags, mute: mutes }))).toEqual(true);
162+
expect(shown(makeState({ flags, mute: muteTopic }))).toEqual(true);
163163
});
164164
});
165165

@@ -168,16 +168,16 @@ describe('getShownMessagesForNarrow', () => {
168168
const makeState = extra => makeStateGeneral(message, narrow, extra);
169169
const shown = state => shownGeneral(state, narrow);
170170

171-
test('message not muted even if stream not subscribed', () => {
171+
test('message shown even if not subscribed to stream', () => {
172172
expect(shown(makeState({ subscriptions: [] }))).toEqual(true);
173173
});
174174

175-
test('message not muted even if stream is muted', () => {
175+
test('message shown even if stream muted', () => {
176176
expect(shown(makeState({ subscriptions: [mutedSubscription] }))).toEqual(true);
177177
});
178178

179-
test('message not muted even if topic is muted', () => {
180-
expect(shown(makeState({ mute: mutes }))).toEqual(true);
179+
test('message shown even if topic muted', () => {
180+
expect(shown(makeState({ mute: muteTopic }))).toEqual(true);
181181
});
182182
});
183183

@@ -186,16 +186,16 @@ describe('getShownMessagesForNarrow', () => {
186186
const makeState = extra => makeStateGeneral(message, narrow, extra);
187187
const shown = state => shownGeneral(state, narrow);
188188

189-
test('message not muted even if stream not subscribed', () => {
189+
test('message shown even if not subscribed to stream', () => {
190190
expect(shown(makeState({ subscriptions: [] }))).toEqual(true);
191191
});
192192

193-
test('message not muted even if stream is muted', () => {
193+
test('message shown even if stream muted', () => {
194194
expect(shown(makeState({ subscriptions: [mutedSubscription] }))).toEqual(true);
195195
});
196196

197-
test('message not muted even if topic is muted', () => {
198-
expect(shown(makeState({ mute: mutes }))).toEqual(true);
197+
test('message shown even if topic muted', () => {
198+
expect(shown(makeState({ mute: muteTopic }))).toEqual(true);
199199
});
200200
});
201201

@@ -204,16 +204,16 @@ describe('getShownMessagesForNarrow', () => {
204204
const makeState = extra => makeStateGeneral(message, narrow, extra);
205205
const shown = state => shownGeneral(state, narrow);
206206

207-
test('message not muted even if stream not subscribed', () => {
207+
test('message shown even if not subscribed to stream', () => {
208208
expect(shown(makeState({ subscriptions: [] }))).toEqual(true);
209209
});
210210

211-
test('message not muted even if stream is muted', () => {
211+
test('message shown even if stream muted', () => {
212212
expect(shown(makeState({ subscriptions: [mutedSubscription] }))).toEqual(true);
213213
});
214214

215-
test('message not muted even if topic is muted', () => {
216-
expect(shown(makeState({ mute: mutes }))).toEqual(true);
215+
test('message shown even if topic muted', () => {
216+
expect(shown(makeState({ mute: muteTopic }))).toEqual(true);
217217
});
218218
});
219219
});

0 commit comments

Comments
 (0)