File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -16,48 +16,51 @@ function compareKeys (...expected) {
16
16
* @returns {boolean }
17
17
*/
18
18
return function ( error ) {
19
- let actual = [ ] ;
19
+ let actual = new Set ( ) ;
20
20
21
21
// Make sure all the specified keys exist
22
22
for ( let key of expected ) {
23
23
if ( key in error ) {
24
- actual . push ( key ) ;
24
+ actual . add ( key ) ;
25
25
}
26
26
}
27
27
28
28
// Make sure the error doesn't have any extra keys
29
29
// eslint-disable-next-line guard-for-in
30
30
for ( let key in error ) {
31
- if ( ! actual . includes ( key ) ) {
32
- actual . push ( key ) ;
33
- }
31
+ actual . add ( key ) ;
34
32
}
35
33
36
34
if ( host . error . hasColumn && "column" in error ) {
35
+ actual . add ( "column" ) ;
37
36
expected . push ( "column" ) ;
38
37
}
39
38
40
39
if ( host . error . hasLine && "line" in error ) {
40
+ actual . add ( "line" ) ;
41
41
expected . push ( "line" ) ;
42
42
}
43
43
44
44
if ( host . error . hasSourceURL && "sourceURL" in error ) {
45
+ actual . add ( "sourceURL" ) ;
45
46
expected . push ( "sourceURL" ) ;
46
47
}
47
48
48
49
if ( host . error . hasEnumerableDescription && "description" in error ) {
50
+ actual . add ( "description" ) ;
49
51
expected . push ( "description" ) ;
50
52
}
51
53
52
54
try {
55
+ actual = [ ...actual ] ;
53
56
expect ( actual ) . to . have . same . members ( expected ) ;
54
57
}
55
58
catch ( e ) {
56
59
console . error ( `
57
- EXPECTED:
60
+ EXPECTED KEYS :
58
61
${ expected . join ( "\n " ) }
59
62
60
- ACTUAL:
63
+ ACTUAL KEYS :
61
64
${ actual . join ( "\n " ) }
62
65
` ) ;
63
66
throw e ;
You can’t perform that action at this time.
0 commit comments