Skip to content

Commit

Permalink
fixes properties
Browse files Browse the repository at this point in the history
  • Loading branch information
bakamitai456 committed Jun 15, 2023
1 parent 79d3d7d commit 6b1a6ed
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,9 @@ Expected properties has value: <g>[Function]</>
exports[`matcher error toMatchNamedSnapshot Expected properties must be an object (null) with snapshot name 1`] = `
<d>expect(</><r>received</><d>).</>toMatchNamedSnapshot<d>(</><g>properties</><d>)</>

Snapshot state must be initialized

Snapshot state has value: undefined
`;

exports[`matcher error toMatchNamedSnapshot Expected properties must be an object (null) without snapshot name 1`] = `
<d>expect(</><r>received</><d>).</>toMatchNamedSnapshot<d>(</><g>properties</><d>)</>

Snapshot state must be initialized
<b>Matcher error</>: Expected <g>properties</> must be an object

Snapshot state has value: undefined
Expected properties has value: <g>null</>
`;

exports[`matcher error toMatchNamedSnapshot Snapshot state must be initialized 1`] = `
Expand Down
17 changes: 1 addition & 16 deletions packages/jest-snapshot/src/__tests__/printSnapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,29 +311,14 @@ describe('matcher error', () => {
}).toThrowErrorMatchingSnapshot();
});

test('Expected properties must be an object (null) without snapshot name', () => {
const context = {
isNot: false,
promise: '',
} as Context;
const properties = null;
const snapshotName =
'toMatchNamedSnapshot Expected properties must be an object (null) without snapshot name';

expect(() => {
// @ts-expect-error: Testing runtime error
toMatchNamedSnapshot.call(context, received, snapshotName, properties);
}).toThrowErrorMatchingSnapshot();
});

test('Expected properties must be an object (array)', () => {
const context = {
isNot: false,
promise: '',
} as Context;
const properties: Array<unknown> = [];
const snapshotName =
'toMatchNamedSnapshot Expected properties must be an object (null) without snapshot name';
'toMatchNamedSnapshot Expected properties must be an object (array)';

expect(() => {
toMatchNamedSnapshot.call(context, received, snapshotName, properties);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-snapshot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export const toMatchNamedSnapshot: MatcherFunctionWithContext<
> = function (received, snapshotName, properties?) {
const matcherName = 'toMatchNamedSnapshot';

if (properties) {
if (properties !== undefined) {
if (
Array.isArray(properties) ||
typeof properties !== 'object' ||
Expand Down

0 comments on commit 6b1a6ed

Please sign in to comment.