Skip to content

Commit

Permalink
test: update assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 7, 2024
1 parent c07b7ef commit c43f1ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
11 changes: 2 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions test/experimental.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,26 +181,26 @@ describe('experimental: type-level RegExp match for type safe match results', ()
]
`)
expectTypeOf(matchResult?._matchArray).toEqualTypeOf<
['bazqux', 'bazqux', 'baz'] | ['barqux', 'barqux', 'bar'] | undefined
['barqux', 'barqux', 'bar']
>()

expect(matchResult?.[0]).toMatchInlineSnapshot('"barqux"')
expectTypeOf(matchResult?.[0]).toEqualTypeOf<'bazqux' | 'barqux' | undefined>()
expectTypeOf(matchResult?.[0]).toEqualTypeOf<'barqux'>()

expect(matchResult?.[1]).toMatchInlineSnapshot('"barqux"')
expectTypeOf(matchResult?.[1]).toEqualTypeOf<'bazqux' | 'barqux' | undefined>()
expectTypeOf(matchResult?.[1]).toEqualTypeOf<'barqux'>()

expect(matchResult?.[2]).toMatchInlineSnapshot('"bar"')
expectTypeOf(matchResult?.[2]).toEqualTypeOf<'bar' | 'baz' | undefined>()
expectTypeOf(matchResult?.[2]).toEqualTypeOf<'bar'>()

// @ts-expect-error - Element implicitly has an 'any' type because expression of type '3' can't be used to index
expect(matchResult?.[3]).toMatchInlineSnapshot('undefined')

expect(matchResult?.index).toMatchInlineSnapshot('1')
expectTypeOf(matchResult?.index).toEqualTypeOf<number | undefined>()
expectTypeOf(matchResult?.index).toEqualTypeOf<1>()

expect(matchResult?.length).toMatchInlineSnapshot('3')
expectTypeOf(matchResult?.length).toEqualTypeOf<3 | undefined>()
expectTypeOf(matchResult?.length).toEqualTypeOf<3>()

expect(matchResult?.groups).toMatchInlineSnapshot(`
{
Expand All @@ -209,7 +209,7 @@ describe('experimental: type-level RegExp match for type safe match results', ()
}
`)
expectTypeOf(matchResult?.groups).toEqualTypeOf<
{ g1: 'bar' | 'baz', g2: 'bazqux' | 'barqux' } | undefined
{ g1: 'bar', g2: 'barqux' }
>()
})
})

0 comments on commit c43f1ff

Please sign in to comment.