@@ -7,7 +7,7 @@ import { createInput } from '../src/core/internal'
7
7
describe ( 'magic-regexp' , ( ) => {
8
8
it ( 'works as a normal regexp' , ( ) => {
9
9
const regExp = createRegExp ( 'in' , [ global ] )
10
- expect ( 'thing' . match ( regExp ) [ 0 ] ) . toMatchInlineSnapshot ( '"in"' )
10
+ expect ( 'thing' . match ( regExp ) ?. [ 0 ] ) . toMatchInlineSnapshot ( '"in"' )
11
11
expect ( regExp . test ( 'thing' ) ) . toBeTruthy ( )
12
12
expect ( regExp . lastIndex ) . toMatchInlineSnapshot ( '4' )
13
13
} )
@@ -27,13 +27,13 @@ describe('inputs', () => {
27
27
it ( 'before' , ( ) => {
28
28
const regExp = createRegExp ( char . before ( 'foo' ) )
29
29
expect ( regExp ) . toMatchInlineSnapshot ( '/\\.\\(\\?=foo\\)/' )
30
- expect ( 'bafoo' . match ( regExp ) [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
30
+ expect ( 'bafoo' . match ( regExp ) ?. [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
31
31
expect ( regExp . test ( 'foo' ) ) . toBeFalsy ( )
32
32
} )
33
33
it ( 'after' , ( ) => {
34
34
const regExp = createRegExp ( char . after ( 'foo' ) )
35
35
expect ( regExp ) . toMatchInlineSnapshot ( '/\\(\\?<=foo\\)\\./' )
36
- expect ( 'fooafoo' . match ( regExp ) [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
36
+ expect ( 'fooafoo' . match ( regExp ) ?. [ 0 ] ) . toMatchInlineSnapshot ( '"a"' )
37
37
expect ( regExp . test ( 'foo' ) ) . toBeFalsy ( )
38
38
} )
39
39
it ( 'notBefore' , ( ) => {
@@ -59,21 +59,21 @@ describe('inputs', () => {
59
59
it ( 'capture groups' , ( ) => {
60
60
const pattern = anyOf ( anyOf ( 'foo' , 'bar' ) . as ( 'test' ) , exactly ( 'baz' ) . as ( 'test2' ) )
61
61
62
- expect ( 'football' . match ( createRegExp ( pattern ) ) . groups ) . toMatchInlineSnapshot ( `
62
+ expect ( 'football' . match ( createRegExp ( pattern ) ) ? .groups ) . toMatchInlineSnapshot ( `
63
63
{
64
64
"test": "foo",
65
65
"test2": undefined,
66
66
}
67
67
` )
68
- expect ( 'fobazzer' . match ( createRegExp ( pattern ) ) . groups ) . toMatchInlineSnapshot ( `
68
+ expect ( 'fobazzer' . match ( createRegExp ( pattern ) ) ? .groups ) . toMatchInlineSnapshot ( `
69
69
{
70
70
"test": undefined,
71
71
"test2": "baz",
72
72
}
73
73
` )
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
+ > ( )
77
77
// @ts -expect-error
78
78
'fobazzer' . match ( createRegExp ( pattern ) ) ?. groups . other
79
79
@@ -84,7 +84,7 @@ describe('inputs', () => {
84
84
"test2": "baz",
85
85
}
86
86
` )
87
- expectTypeOf < Record < 'test' | 'test2' , string | undefined > > ( match . groups )
87
+ expectTypeOf ( match . groups ) . toMatchTypeOf < Record < 'test' | 'test2' , string | undefined > > ( )
88
88
}
89
89
} )
90
90
} )
0 commit comments