@@ -7,7 +7,7 @@ import { createInput } from '../src/core/internal'
77describe ( 'magic-regexp' , ( ) => {
88 it ( 'works as a normal regexp' , ( ) => {
99 const regExp = createRegExp ( 'in' , [ global ] )
10- expect ( 'thing' . match ( regExp ) [ 0 ] ) . toMatchInlineSnapshot ( '"in"' )
10+ expect ( 'thing' . match ( regExp ) ?. [ 0 ] ) . toMatchInlineSnapshot ( '"in"' )
1111 expect ( regExp . test ( 'thing' ) ) . toBeTruthy ( )
1212 expect ( regExp . lastIndex ) . toMatchInlineSnapshot ( '4' )
1313 } )
@@ -27,13 +27,13 @@ describe('inputs', () => {
2727 it ( 'before' , ( ) => {
2828 const regExp = createRegExp ( char . before ( 'foo' ) )
2929 expect ( regExp ) . toMatchInlineSnapshot ( '/\\.\\(\\?=foo\\)/' )
30- expect ( 'bafoo' . match ( regExp ) [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
30+ expect ( 'bafoo' . match ( regExp ) ?. [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
3131 expect ( regExp . test ( 'foo' ) ) . toBeFalsy ( )
3232 } )
3333 it ( 'after' , ( ) => {
3434 const regExp = createRegExp ( char . after ( 'foo' ) )
3535 expect ( regExp ) . toMatchInlineSnapshot ( '/\\(\\?<=foo\\)\\./' )
36- expect ( 'fooafoo' . match ( regExp ) [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
36+ expect ( 'fooafoo' . match ( regExp ) ?. [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
3737 expect ( regExp . test ( 'foo' ) ) . toBeFalsy ( )
3838 } )
3939 it ( 'notBefore' , ( ) => {
@@ -59,21 +59,21 @@ describe('inputs', () => {
5959 it ( 'capture groups' , ( ) => {
6060 const pattern = anyOf ( anyOf ( 'foo' , 'bar' ) . as ( 'test' ) , exactly ( 'baz' ) . as ( 'test2' ) )
6161
62- expect ( 'football' . match ( createRegExp ( pattern ) ) . groups ) . toMatchInlineSnapshot ( `
62+ expect ( 'football' . match ( createRegExp ( pattern ) ) ? .groups ) . toMatchInlineSnapshot ( `
6363 {
6464 "test": "foo",
6565 "test2": undefined,
6666 }
6767 ` )
68- expect ( 'fobazzer' . match ( createRegExp ( pattern ) ) . groups ) . toMatchInlineSnapshot ( `
68+ expect ( 'fobazzer' . match ( createRegExp ( pattern ) ) ? .groups ) . toMatchInlineSnapshot ( `
6969 {
7070 "test": undefined,
7171 "test2": "baz",
7272 }
7373 ` )
74- expectTypeOf < Record < 'test' | 'test2' , string | undefined > | undefined > (
75- 'fobazzer' . match ( createRegExp ( pattern ) ) ?. groups
76- )
74+ expectTypeOf ( 'fobazzer' . match ( createRegExp ( pattern ) ) ?. groups ) . toMatchTypeOf <
75+ Record < 'test' | 'test2' , string | undefined > | undefined
76+ > ( )
7777 // @ts -expect-error
7878 'fobazzer' . match ( createRegExp ( pattern ) ) ?. groups . other
7979
@@ -84,7 +84,7 @@ describe('inputs', () => {
8484 "test2": "baz",
8585 }
8686 ` )
87- expectTypeOf < Record < 'test' | 'test2' , string | undefined > > ( match . groups )
87+ expectTypeOf ( match . groups ) . toMatchTypeOf < Record < 'test' | 'test2' , string | undefined > > ( )
8888 }
8989 } )
9090} )
0 commit comments