File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -28,3 +28,10 @@ test('regex constructor', () => {
28
28
expect ( buildRegex ( 'a' ) . test ( 'a' ) ) . toBeTruthy ( ) ;
29
29
expect ( buildRegex ( 'a' ) . test ( 'b' ) ) . toBeFalsy ( ) ;
30
30
} ) ;
31
+
32
+ test ( 'buildRegex throws error on unknown element' , ( ) => {
33
+ expect ( ( ) =>
34
+ // @ts -expect-error intentionally passing incorrect object
35
+ buildRegex ( { type : 'unknown' } )
36
+ ) . toThrowErrorMatchingInlineSnapshot ( `"Unknown elements type unknown"` ) ;
37
+ } ) ;
Original file line number Diff line number Diff line change @@ -38,13 +38,13 @@ function compileSingle(element: RegexElement): string {
38
38
return compileCharacterClass ( element ) ;
39
39
}
40
40
41
- const compiledChildren = compileList ( element . children ) ;
42
-
43
41
if ( element . type === 'repeat' ) {
42
+ const compiledChildren = compileList ( element . children ) ;
44
43
return compileRepeat ( element . config , compiledChildren ) ;
45
44
}
46
45
47
46
if ( isBaseQuantifier ( element ) ) {
47
+ const compiledChildren = compileList ( element . children ) ;
48
48
const compiler = baseQuantifiers [ element . type ] ;
49
49
return compiler ( compiledChildren ) ;
50
50
}
You can’t perform that action at this time.
0 commit comments