Skip to content

Commit

Permalink
feat(select): add unit tests for variadic tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
gvergnaud committed Aug 6, 2023
1 parent 171c51d commit 5edaca4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,4 +466,24 @@ describe('select', () => {

expect(res3).toEqual({ a: [] });
});

it('should work with variadic tuples', () => {
const fn = (input: string[]) =>
match(input)
.with(
[P.string, 'some', 'cli', 'cmd', P.select(), ...P.array()],
(arg) => {
type t = Expect<Equal<typeof arg, string>>;
return arg;
}
)
.otherwise(() => '2');

expect(fn(['some cli cmd param', 'some', 'cli', 'cmd', 'param'])).toEqual(
'param'
);
expect(
fn(['some cli cmd param --flag', 'some', 'cli', 'cmd', 'param', '--flag'])
).toEqual('param');
});
});

0 comments on commit 5edaca4

Please sign in to comment.