1
1
require ( "../src/index" ) ;
2
2
3
3
const { describe, expect, it } = require ( "@jest/globals" ) ;
4
- const { LINE_TERMINATOR } = require ( "../src/utils" ) ;
4
+ const { LINE_TERMINATOR , joinRight } = require ( "../src/utils" ) ;
5
5
6
6
describe ( "extended matchers" , ( ) => {
7
7
describe ( "toLog" , ( ) => {
@@ -25,13 +25,13 @@ describe("extended matchers", () => {
25
25
console . log ( { 1 : 1 , 2 : [ 3 , 4 , 5 ] } , [ 100 , 200 , 300 ] , undefined , null ) ;
26
26
}
27
27
28
- const expectedString =
29
- "{} []" +
30
- LINE_TERMINATOR +
31
- "[] {}" +
32
- LINE_TERMINATOR +
33
- "{ '1': 1, '2': [ 3, 4, 5 ] } [ 100, 200, 300 ] undefined null" +
34
- LINE_TERMINATOR ;
28
+ const expectedStringArr = [
29
+ "{} []" ,
30
+ "[] {}" ,
31
+ "{ '1': 1, '2': [ 3, 4, 5 ] } [ 100, 200, 300 ] undefined null" ,
32
+ ] ;
33
+
34
+ const expectedString = joinRight ( expectedStringArr , LINE_TERMINATOR ) ;
35
35
expect ( testFn ) . toLog ( expectedString ) ;
36
36
} ) ;
37
37
} ) ;
@@ -60,14 +60,13 @@ describe("extended matchers", () => {
60
60
) ;
61
61
}
62
62
63
- const expectedString =
64
- "Vello 300" +
65
- LINE_TERMINATOR +
66
- "Vello 400" +
67
- LINE_TERMINATOR +
68
- "{ '1': 1, '2': [ 3, 4, 5 ] } [ 100, 200, 300 ] undefined null" +
69
- LINE_TERMINATOR ;
63
+ const expectedStringArr = [
64
+ "Vello 300" ,
65
+ "Vello 400" ,
66
+ "{ '1': 1, '2': [ 3, 4, 5 ] } [ 100, 200, 300 ] undefined null" ,
67
+ ] ;
70
68
69
+ const expectedString = joinRight ( expectedStringArr , LINE_TERMINATOR ) ;
71
70
expect ( testFn ) . toLog ( expectedString ) ;
72
71
} ) ;
73
72
} ) ;
@@ -95,14 +94,13 @@ describe("extended matchers", () => {
95
94
) ;
96
95
}
97
96
98
- const expectedString =
99
- "Cello 300" +
100
- LINE_TERMINATOR +
101
- "Cello 400" +
102
- LINE_TERMINATOR +
103
- "{ '1': 1, '2': [ 3, 4, 5 ] } [ 100, 200, 300 ] undefined null" +
104
- LINE_TERMINATOR ;
97
+ const expectedStringArr = [
98
+ "Cello 300" ,
99
+ "Cello 400" ,
100
+ "{ '1': 1, '2': [ 3, 4, 5 ] } [ 100, 200, 300 ] undefined null" ,
101
+ ] ;
105
102
103
+ const expectedString = joinRight ( expectedStringArr , LINE_TERMINATOR ) ;
106
104
expect ( testFn ) . toLog ( expectedString ) ;
107
105
} ) ;
108
106
} ) ;
@@ -177,17 +175,14 @@ describe("extended matchers", () => {
177
175
console . error ( "Gello 123" ) ;
178
176
}
179
177
180
- const expected =
181
- "Jello warning" +
182
- LINE_TERMINATOR +
183
- "Gello error" +
184
- LINE_TERMINATOR +
185
- "Jello 123" +
186
- LINE_TERMINATOR +
187
- "Gello 123" +
188
- LINE_TERMINATOR ;
189
-
190
- expect ( testFn ) . toLogErrorOrWarn ( expected ) ;
178
+ const expectedStringArr = [
179
+ "Jello warning" ,
180
+ "Gello error" ,
181
+ "Jello 123" ,
182
+ "Gello 123" ,
183
+ ] ;
184
+ const expectedString = joinRight ( expectedStringArr , LINE_TERMINATOR ) ;
185
+ expect ( testFn ) . toLogErrorOrWarn ( expectedString ) ;
191
186
} ) ;
192
187
193
188
it ( "should not honor other methods" , ( ) => {
@@ -241,11 +236,10 @@ describe("extended matchers", () => {
241
236
}
242
237
243
238
await expect ( asyncTestFn ) . toLog (
244
- [ "ASYNC log" , "ASYNC info" , "ASYNC debug" ] . join ( LINE_TERMINATOR ) +
245
- LINE_TERMINATOR
239
+ joinRight ( [ "ASYNC log" , "ASYNC info" , "ASYNC debug" ] , LINE_TERMINATOR )
246
240
) ;
247
241
await expect ( asyncTestFn ) . toLogErrorOrWarn (
248
- [ "ASYNC warn" , "ASYNC error" ] . join ( LINE_TERMINATOR ) + LINE_TERMINATOR
242
+ joinRight ( [ "ASYNC warn" , "ASYNC error" ] , LINE_TERMINATOR )
249
243
) ;
250
244
} ) ;
251
245
0 commit comments