@@ -32,21 +32,34 @@ describe('kuvio', () => {
32
32
k . or ( k . atLeast ( 2 ) ( k . exactString ( 'bar' ) ) ) ,
33
33
)
34
34
35
+ const testPattern =
36
+ "(((foo){5,9}z+?y+)?.*.*?.*?[^a-z]{3}[0-4A#-'Q-T\\x1f-\\x2d\\x5e-\\x7f\\xff-\\u0100])|(bar){2,}"
37
+
35
38
it ( 'can create RegExps' , ( ) => {
36
39
const actual = k . regexFromPattern ( pattern )
37
40
38
- expect ( actual . source ) . toEqual (
39
- "^((((foo){5,9}z+?y+)?.*.*?.*?[^a-z]{3}[0-4A#-'Q-T\\x1f-\\x2d\\x5e-\\x7f\\xff-\\u0100])|(bar){2,})$" ,
40
- )
41
+ expect ( actual . source ) . toEqual ( `^(${ testPattern } )$` )
41
42
expect ( actual . flags ) . toEqual ( '' )
42
43
} )
43
44
44
45
it ( 'can create case-insensitive RegExps' , ( ) => {
45
46
const actual = k . regexFromPattern ( pattern , true )
46
47
47
- expect ( actual . source ) . toEqual (
48
- "^((((foo){5,9}z+?y+)?.*.*?.*?[^a-z]{3}[0-4A#-'Q-T\\x1f-\\x2d\\x5e-\\x7f\\xff-\\u0100])|(bar){2,})$" ,
49
- )
48
+ expect ( actual . source ) . toEqual ( `^(${ testPattern } )$` )
50
49
expect ( actual . flags ) . toEqual ( 'i' )
51
50
} )
51
+
52
+ it ( 'can create global RegExps' , ( ) => {
53
+ const actual = k . regexFromPattern ( pattern , false , true )
54
+
55
+ expect ( actual . source ) . toEqual ( testPattern )
56
+ expect ( actual . flags ) . toEqual ( 'g' )
57
+ } )
58
+
59
+ it ( 'can create multiline RegExps' , ( ) => {
60
+ const actual = k . regexFromPattern ( pattern , false , false , true )
61
+
62
+ expect ( actual . source ) . toEqual ( `^(${ testPattern } )$` )
63
+ expect ( actual . flags ) . toEqual ( 'm' )
64
+ } )
52
65
} )
0 commit comments