Skip to content

Commit

Permalink
refactor: move test to exhaustive-match.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
changwoolab committed Sep 23, 2024
1 parent d2fb2ed commit 980e4d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 11 additions & 0 deletions tests/exhaustive-match.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -979,4 +979,15 @@ describe('exhaustive()', () => {
expect(withoutTypo({ sex: 'b', age: 'c' })).toBe(1);
});
});

it('issue #271: P.array should support readonly arrays as its input', () => {
type Input = string | Date | readonly string[];
const input = ['a', 'b', 'c'] as Input;

const output = match(input)
.with(P.array(P.string), (value) => 2)
.with(P.string, (value) => 1)
.with(P.instanceOf(Date), (value) => 3)
.exhaustive();
});
});
11 changes: 0 additions & 11 deletions tests/lists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ describe('List ([a])', () => {
.otherwise(() => 'something else');
});

it('issue #271: P.array should support readonly arrays as its input', () => {
type Input = string | Date | readonly string[];
const input = ['a', 'b', 'c'] as Input;

const output = match(input)
.with(P.array(P.string), (value) => 2)
.with(P.string, (value) => 1)
.with(P.instanceOf(Date), (value) => 3)
.exhaustive();
});

it('type narrowing should work on nested arrays', () => {
const fn = (input: { queries?: { q?: string[]; a: number }[] }) =>
match(input).with(
Expand Down

0 comments on commit 980e4d0

Please sign in to comment.