Skip to content

Commit ea68dcc

Browse files
committed
Fix and test inspection of Date and Buffer instances
1 parent 006470d commit ea68dcc

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

lib/isSimpleObjectTree.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ function isSimpleObjectTree(obj, expect) {
2828
'null',
2929
'undefined',
3030
'string',
31-
'Buffer'
31+
'Buffer',
32+
'infiniteBuffer', // expectForRendering's hack
33+
'date'
3234
].includes(type.name);
3335
}
3436
}

test/unexpected-snapshot.js

+50
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,56 @@ it('should foo', function() {
408408
);
409409
});
410410

411+
it('should support injecting certain safe built-in types in a literal snapshot', function() {
412+
return expect(
413+
() => {
414+
it('should foo', function() {
415+
expect(
416+
{
417+
date: new Date('2019-05-09T12:34:56.789Z'),
418+
buffer: Buffer.from([0xde, 0xad, 0xbe, 0xef]),
419+
undefined: undefined,
420+
null: null,
421+
NaN: NaN,
422+
Infinity: Infinity,
423+
number: 123.456,
424+
regexp: /abc(?:)/gim
425+
},
426+
'to equal snapshot'
427+
);
428+
});
429+
},
430+
'to come out as',
431+
() => {
432+
it('should foo', function() {
433+
expect(
434+
{
435+
date: new Date('2019-05-09T12:34:56.789Z'),
436+
buffer: Buffer.from([0xde, 0xad, 0xbe, 0xef]),
437+
undefined: undefined,
438+
null: null,
439+
NaN: NaN,
440+
Infinity: Infinity,
441+
number: 123.456,
442+
regexp: /abc(?:)/gim
443+
},
444+
'to equal snapshot',
445+
{
446+
date: new Date('Thu, 09 May 2019 12:34:56.789 GMT'),
447+
buffer: new Buffer([0xde, 0xad, 0xbe, 0xef]),
448+
undefined: undefined,
449+
null: null,
450+
NaN: NaN,
451+
Infinity: Infinity,
452+
number: 123.456,
453+
regexp: /abc(?:)/gim
454+
}
455+
);
456+
});
457+
}
458+
);
459+
});
460+
411461
describe.skip('with expect.it', function() {
412462
it('should fill in a missing string', function() {
413463
return expect(

0 commit comments

Comments
 (0)