@@ -60,11 +60,11 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
60
60
public toContainKey ( key : keyof T ) : this {
61
61
const error = new AssertionError ( {
62
62
actual : this . actual ,
63
- message : `Expected the object to contain the provided key <${ String ( key ) } >` ,
63
+ message : `Expected the object to contain the provided key <${ prettify ( key ) } >` ,
64
64
} ) ;
65
65
const invertedError = new AssertionError ( {
66
66
actual : this . actual ,
67
- message : `Expected the object NOT to contain the provided key <${ String ( key ) } >` ,
67
+ message : `Expected the object NOT to contain the provided key <${ prettify ( key ) } >` ,
68
68
} ) ;
69
69
70
70
return this . execute ( {
@@ -86,14 +86,15 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
86
86
* @returns the assertion instance
87
87
*/
88
88
public toContainAllKeys ( ...keys : Array < keyof T > ) : this {
89
+ const allKeys = keys . map ( prettify ) . join ( ", " ) ;
89
90
const error = new AssertionError ( {
90
91
actual : Object . keys ( this . actual ) ,
91
92
expected : keys ,
92
- message : `Expected the object to contain all the provided keys <${ prettify ( keys ) } >` ,
93
+ message : `Expected the object to contain all the provided keys <${ allKeys } >` ,
93
94
} ) ;
94
95
const invertedError = new AssertionError ( {
95
96
actual : Object . keys ( this . actual ) ,
96
- message : `Expected the object NOT to contain all the provided keys <${ prettify ( keys ) } >` ,
97
+ message : `Expected the object NOT to contain all the provided keys <${ allKeys } >` ,
97
98
} ) ;
98
99
99
100
return this . execute ( {
@@ -115,14 +116,15 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
115
116
* @returns the assertion instance
116
117
*/
117
118
public toContainAnyKeys ( ...keys : Array < keyof T > ) : this {
119
+ const allKeys = keys . map ( prettify ) . join ( ", " ) ;
118
120
const error = new AssertionError ( {
119
121
actual : Object . keys ( this . actual ) ,
120
122
expected : keys ,
121
- message : `Expected the object to contain at least one of the provided keys <${ prettify ( keys ) } >` ,
123
+ message : `Expected the object to contain at least one of the provided keys <${ allKeys } >` ,
122
124
} ) ;
123
125
const invertedError = new AssertionError ( {
124
126
actual : Object . keys ( this . actual ) ,
125
- message : `Expected the object NOT to contain any of the provided keys <${ prettify ( keys ) } >` ,
127
+ message : `Expected the object NOT to contain any of the provided keys <${ allKeys } >` ,
126
128
} ) ;
127
129
128
130
return this . execute ( {
@@ -146,15 +148,16 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
146
148
public toHaveKeys ( ...keys : Array < keyof T > ) : this {
147
149
const sortedActual = Object . keys ( this . actual ) . sort ( ) ;
148
150
const sortedKeys = [ ...keys ] . sort ( ) ;
151
+ const allKeys = sortedKeys . map ( prettify ) . join ( ", " ) ;
149
152
150
153
const error = new AssertionError ( {
151
154
actual : sortedActual ,
152
155
expected : sortedKeys ,
153
- message : `Expected the object to have exactly the keys <${ prettify ( sortedKeys ) } >` ,
156
+ message : `Expected the object to have exactly the keys <${ allKeys } >` ,
154
157
} ) ;
155
158
const invertedError = new AssertionError ( {
156
159
actual : sortedActual ,
157
- message : `Expected the object NOT to have the keys <${ prettify ( sortedKeys ) } >` ,
160
+ message : `Expected the object NOT to have the keys <${ allKeys } >` ,
158
161
} ) ;
159
162
160
163
return this . execute ( {
@@ -205,14 +208,15 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
205
208
* @returns the assertion instance
206
209
*/
207
210
public toContainAllValues ( ...values : Array < T [ keyof T ] > ) : this {
211
+ const allValues = values . map ( prettify ) . join ( ", " ) ;
208
212
const error = new AssertionError ( {
209
213
actual : Object . values ( this . actual ) ,
210
214
expected : values ,
211
- message : `Expected the object to contain all the provided values <${ prettify ( values ) } >` ,
215
+ message : `Expected the object to contain all the provided values <${ allValues } >` ,
212
216
} ) ;
213
217
const invertedError = new AssertionError ( {
214
218
actual : Object . values ( this . actual ) ,
215
- message : `Expected the object NOT to contain all the provided values <${ prettify ( values ) } >` ,
219
+ message : `Expected the object NOT to contain all the provided values <${ allValues } >` ,
216
220
} ) ;
217
221
218
222
return this . execute ( {
@@ -237,14 +241,15 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
237
241
* @returns the assertion instance
238
242
*/
239
243
public toContainAnyValues ( ...values : Array < T [ keyof T ] > ) : this {
244
+ const allValues = values . map ( prettify ) . join ( ", " ) ;
240
245
const error = new AssertionError ( {
241
246
actual : Object . values ( this . actual ) ,
242
247
expected : values ,
243
- message : `Expected the object to contain at least one of the provided values <${ prettify ( values ) } >` ,
248
+ message : `Expected the object to contain at least one of the provided values <${ allValues } >` ,
244
249
} ) ;
245
250
const invertedError = new AssertionError ( {
246
251
actual : Object . values ( this . actual ) ,
247
- message : `Expected the object NOT to contain any of the provided values <${ prettify ( values ) } >` ,
252
+ message : `Expected the object NOT to contain any of the provided values <${ allValues } >` ,
248
253
} ) ;
249
254
250
255
return this . execute ( {
@@ -271,15 +276,16 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
271
276
public toHaveValues ( ...values : Array < T [ keyof T ] > ) : this {
272
277
const sortedActual = Object . values ( this . actual ) . sort ( ) ;
273
278
const sorterdValues = [ ...values ] . sort ( ) ;
279
+ const allValues = sorterdValues . map ( prettify ) . join ( ", " ) ;
274
280
275
281
const error = new AssertionError ( {
276
282
actual : sortedActual ,
277
283
expected : sorterdValues ,
278
- message : `Expected the object to have exactly the values <${ prettify ( sorterdValues ) } >` ,
284
+ message : `Expected the object to have exactly the values <${ allValues } >` ,
279
285
} ) ;
280
286
const invertedError = new AssertionError ( {
281
287
actual : sortedActual ,
282
- message : `Expected the object NOT to have the values <${ prettify ( sorterdValues ) } >` ,
288
+ message : `Expected the object NOT to have the values <${ allValues } >` ,
283
289
} ) ;
284
290
285
291
return this . execute ( {
@@ -331,15 +337,16 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
331
337
* @returns the assertion instance
332
338
*/
333
339
public toContainAllEntries ( ...entries : Entry < T > [ ] ) : this {
340
+ const allEntries = entries . map ( prettify ) . join ( ", " ) ;
334
341
const error = new AssertionError ( {
335
342
actual : Object . entries ( this . actual ) ,
336
343
expected : entries ,
337
- message : `Expected the object to contain all the provided entries <${ prettify ( entries ) } >` ,
344
+ message : `Expected the object to contain all the provided entries <${ allEntries } >` ,
338
345
} ) ;
339
346
340
347
const invertedError = new AssertionError ( {
341
348
actual : Object . entries ( this . actual ) ,
342
- message : `Expected the object NOT to contain all the provided entries <${ prettify ( entries ) } >` ,
349
+ message : `Expected the object NOT to contain all the provided entries <${ allEntries } >` ,
343
350
} ) ;
344
351
return this . execute ( {
345
352
assertWhen : entries
@@ -365,15 +372,16 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
365
372
* @returns the assertion instance
366
373
*/
367
374
public toContainAnyEntries ( ...entries : Entry < T > [ ] ) : this {
375
+ const allEntries = entries . map ( prettify ) . join ( ", " ) ;
368
376
const error = new AssertionError ( {
369
377
actual : Object . entries ( this . actual ) ,
370
378
expected : entries ,
371
- message : `Expected the object to contain at least one of the provided entries <${ prettify ( entries ) } >` ,
379
+ message : `Expected the object to contain at least one of the provided entries <${ allEntries } >` ,
372
380
} ) ;
373
381
374
382
const invertedError = new AssertionError ( {
375
383
actual : Object . entries ( this . actual ) ,
376
- message : `Expected the object NOT to contain any of the provided entries <${ prettify ( entries ) } >` ,
384
+ message : `Expected the object NOT to contain any of the provided entries <${ allEntries } >` ,
377
385
} ) ;
378
386
return this . execute ( {
379
387
assertWhen : entries
@@ -401,15 +409,15 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
401
409
public toHaveEntries ( ...entries : Entry < T > [ ] ) : this {
402
410
const sortedActual = Object . entries ( this . actual ) . sort ( ) ;
403
411
const sortedEntries = [ ...entries ] . sort ( ) ;
404
- const prettyEntries = sortedEntries . map ( entry => `[ ${ prettify ( entry ) } ]` ) . join ( "," ) ;
412
+ const allEntries = sortedEntries . map ( prettify ) . join ( ", " ) ;
405
413
const error = new AssertionError ( {
406
414
actual : sortedActual ,
407
415
expected : sortedEntries ,
408
- message : `Expected the object to have exactly the entries <${ prettyEntries } >` ,
416
+ message : `Expected the object to have exactly the entries <${ allEntries } >` ,
409
417
} ) ;
410
418
const invertedError = new AssertionError ( {
411
419
actual : Object . entries ( this . actual ) ,
412
- message : `Expected the object NOT to have the entries <${ prettyEntries } >` ,
420
+ message : `Expected the object NOT to have the entries <${ allEntries } >` ,
413
421
} ) ;
414
422
415
423
return this . execute ( {
@@ -433,13 +441,12 @@ export class ObjectAssertion<T extends Struct> extends Assertion<T> {
433
441
public toPartiallyMatch ( other : Partial < T > ) : this {
434
442
const error = new AssertionError ( {
435
443
actual : this . actual ,
436
- expected : other ,
437
- message : "Expected the object to be a partial match" ,
444
+ message : `Expected the object to partially match <${ prettify ( other ) } >` ,
438
445
} ) ;
439
446
440
447
const invertedError = new AssertionError ( {
441
448
actual : this . actual ,
442
- message : " Expected the object NOT to be a partial match" ,
449
+ message : ` Expected the object NOT to partially match < ${ prettify ( other ) } >` ,
443
450
} ) ;
444
451
return this . execute ( {
445
452
assertWhen : Object . keys ( other )
0 commit comments