@@ -205,30 +205,24 @@ const generateValidStringLiteralCases = (operator: string, matcher: string) => {
205
205
[ 'x' , "'y'" ] ,
206
206
[ 'x' , '`y`' ] ,
207
207
[ 'x' , '`y${z}`' ] ,
208
- ] . reduce (
209
- ( cases , [ a , b ] ) => [
210
- ...cases ,
211
- ...[
212
- `expect(${ a } ${ operator } ${ b } ).${ matcher } (true)` ,
213
- `expect(${ a } ${ operator } ${ b } ).${ matcher } (false)` ,
214
- `expect(${ a } ${ operator } ${ b } ).not.${ matcher } (true)` ,
215
- `expect(${ a } ${ operator } ${ b } ).not.${ matcher } (false)` ,
216
- `expect(${ a } ${ operator } ${ b } ).resolves.${ matcher } (true)` ,
217
- `expect(${ a } ${ operator } ${ b } ).resolves.${ matcher } (false)` ,
218
- `expect(${ a } ${ operator } ${ b } ).resolves.not.${ matcher } (true)` ,
219
- `expect(${ a } ${ operator } ${ b } ).resolves.not.${ matcher } (false)` ,
220
- `expect(${ b } ${ operator } ${ a } ).resolves.not.${ matcher } (false)` ,
221
- `expect(${ b } ${ operator } ${ a } ).resolves.not.${ matcher } (true)` ,
222
- `expect(${ b } ${ operator } ${ a } ).resolves.${ matcher } (false)` ,
223
- `expect(${ b } ${ operator } ${ a } ).resolves.${ matcher } (true)` ,
224
- `expect(${ b } ${ operator } ${ a } ).not.${ matcher } (false)` ,
225
- `expect(${ b } ${ operator } ${ a } ).not.${ matcher } (true)` ,
226
- `expect(${ b } ${ operator } ${ a } ).${ matcher } (false)` ,
227
- `expect(${ b } ${ operator } ${ a } ).${ matcher } (true)` ,
228
- ] ,
229
- ] ,
230
- [ ] ,
231
- ) ;
208
+ ] . flatMap ( ( [ a , b ] ) => [
209
+ `expect(${ a } ${ operator } ${ b } ).${ matcher } (true)` ,
210
+ `expect(${ a } ${ operator } ${ b } ).${ matcher } (false)` ,
211
+ `expect(${ a } ${ operator } ${ b } ).not.${ matcher } (true)` ,
212
+ `expect(${ a } ${ operator } ${ b } ).not.${ matcher } (false)` ,
213
+ `expect(${ a } ${ operator } ${ b } ).resolves.${ matcher } (true)` ,
214
+ `expect(${ a } ${ operator } ${ b } ).resolves.${ matcher } (false)` ,
215
+ `expect(${ a } ${ operator } ${ b } ).resolves.not.${ matcher } (true)` ,
216
+ `expect(${ a } ${ operator } ${ b } ).resolves.not.${ matcher } (false)` ,
217
+ `expect(${ b } ${ operator } ${ a } ).resolves.not.${ matcher } (false)` ,
218
+ `expect(${ b } ${ operator } ${ a } ).resolves.not.${ matcher } (true)` ,
219
+ `expect(${ b } ${ operator } ${ a } ).resolves.${ matcher } (false)` ,
220
+ `expect(${ b } ${ operator } ${ a } ).resolves.${ matcher } (true)` ,
221
+ `expect(${ b } ${ operator } ${ a } ).not.${ matcher } (false)` ,
222
+ `expect(${ b } ${ operator } ${ a } ).not.${ matcher } (true)` ,
223
+ `expect(${ b } ${ operator } ${ a } ).${ matcher } (false)` ,
224
+ `expect(${ b } ${ operator } ${ a } ).${ matcher } (true)` ,
225
+ ] ) ;
232
226
} ;
233
227
234
228
const testComparisonOperator = (
@@ -244,27 +238,17 @@ const testComparisonOperator = (
244
238
`expect(value).${ preferredMatcherWhenNegated } (1);` ,
245
239
`expect(value).not.${ preferredMatcher } (1);` ,
246
240
`expect(value).not.${ preferredMatcherWhenNegated } (1);` ,
247
- ...[ 'toBe' , 'toEqual' , 'toStrictEqual' ] . reduce < string [ ] > (
248
- ( cases , equalityMatcher ) => [
249
- ...cases ,
250
- ...generateValidStringLiteralCases ( operator , equalityMatcher ) ,
251
- ] ,
252
- [ ] ,
241
+ ...[ 'toBe' , 'toEqual' , 'toStrictEqual' ] . flatMap ( equalityMatcher =>
242
+ generateValidStringLiteralCases ( operator , equalityMatcher ) ,
253
243
) ,
254
244
] ,
255
- invalid : [ 'toBe' , 'toEqual' , 'toStrictEqual' ] . reduce <
256
- Array < TSESLint . InvalidTestCase < 'useToBeComparison' , never > >
257
- > (
258
- ( cases , equalityMatcher ) => [
259
- ...cases ,
260
- ...generateInvalidCases (
261
- operator ,
262
- equalityMatcher ,
263
- preferredMatcher ,
264
- preferredMatcherWhenNegated ,
265
- ) ,
266
- ] ,
267
- [ ] ,
245
+ invalid : [ 'toBe' , 'toEqual' , 'toStrictEqual' ] . flatMap ( equalityMatcher =>
246
+ generateInvalidCases (
247
+ operator ,
248
+ equalityMatcher ,
249
+ preferredMatcher ,
250
+ preferredMatcherWhenNegated ,
251
+ ) ,
268
252
) ,
269
253
} ) ;
270
254
} ;
0 commit comments