Skip to content

Commit

Permalink
add types test
Browse files Browse the repository at this point in the history
  • Loading branch information
bakamitai456 committed Jun 15, 2023
1 parent 6fb5b85 commit f28f669
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions packages/jest-snapshot/__typetests__/matchers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import {
Context,
SnapshotState,
toMatchInlineSnapshot,
toMatchNamedSnapshot,
toMatchSnapshot,
toThrowErrorMatchingInlineSnapshot,
toThrowErrorMatchingNamedSnapshot,
toThrowErrorMatchingSnapshot,
} from 'jest-snapshot';

Expand Down Expand Up @@ -78,6 +80,43 @@ expectType<ExpectationResult>(

expectError(toMatchInlineSnapshot({received: 'value'}));

// toMatchNamedSnapshot

expectType<ExpectationResult>(
toMatchNamedSnapshot.call({} as Context, {received: 'value'}),
);

expectType<ExpectationResult>(
toMatchNamedSnapshot.call({} as Context, {received: 'value'}),
);

expectType<ExpectationResult>(
toMatchNamedSnapshot.call(
{} as Context,
{received: 'value'},
'snapshot name',
),
);

expectType<ExpectationResult>(
toMatchNamedSnapshot.call(
{} as Context,
{received: 'value'},
{property: 'match'},
),
);

expectType<ExpectationResult>(
toMatchNamedSnapshot.call(
{} as Context,
{received: 'value'},
{property: 'match'},
'snapshot name',
),
);

expectError(toMatchNamedSnapshot({received: 'value'}));

// toThrowErrorMatchingSnapshot

expectType<ExpectationResult>(
Expand Down Expand Up @@ -145,3 +184,37 @@ expectType<ExpectationResult>(
);

expectError(toThrowErrorMatchingInlineSnapshot({received: 'value'}));

// toThrowErrorMatchingNamedSnapshot

expectType<ExpectationResult>(
toThrowErrorMatchingNamedSnapshot.call({} as Context, new Error('received')),
);

expectType<ExpectationResult>(
toThrowErrorMatchingNamedSnapshot.call(
{} as Context,
new Error('received'),
'snapshot name',
),
);

expectType<ExpectationResult>(
toThrowErrorMatchingNamedSnapshot.call(
{} as Context,
new Error('received'),
'snapshot name',
true, // fromPromise
),
);

expectType<ExpectationResult>(
toThrowErrorMatchingNamedSnapshot.call(
{} as Context,
new Error('received'),
undefined,
false, // fromPromise
),
);

expectError(toThrowErrorMatchingSnapshot({received: 'value'}));

0 comments on commit f28f669

Please sign in to comment.