1+ import  cases  from  'jest-in-case' 
12import  { fuzzyMatches ,  matches }  from  '../matches' 
23
34// unit tests for text match utils 
@@ -10,12 +11,55 @@ test('matchers accept strings', () => {
1011 expect ( fuzzyMatches ( 'ABC' ,  node ,  'ABC' ,  normalizer ) ) . toBe ( true ) 
1112} ) 
1213
13- test ( 'matchers accept regex' ,  ( )  =>  { 
14-  expect ( matches ( 'ABC' ,  node ,  / A B C / ,  normalizer ) ) . toBe ( true ) 
15-  expect ( fuzzyMatches ( 'ABC' ,  node ,  / A B C / ,  normalizer ) ) . toBe ( true ) 
16- } ) 
14+ cases ( 
15+  'matchers accept regex' , 
16+  ( { textToMatch,  regex} )  =>  { 
17+  expect ( matches ( textToMatch ,  node ,  regex ,  normalizer ) ) . toBe ( true ) 
18+  expect ( fuzzyMatches ( textToMatch ,  node ,  regex ,  normalizer ) ) . toBe ( true ) 
19+  } , 
20+  { 
21+  normal : { 
22+  textToMatch : 'ABC' , 
23+  regex : / A B C / , 
24+  } , 
25+  global : { 
26+  textToMatch : 'ABC' , 
27+  regex : / A B C / g, 
28+  } , 
29+  caseInsensitive : { 
30+  textToMatch : 'ABC' , 
31+  regex : / a b c / i, 
32+  } , 
33+  globalCaseInsensitive : { 
34+  textToMatch : 'AbC' , 
35+  regex : / a b c / gi, 
36+  } , 
37+  multiLine : { 
38+  textToMatch : ` 
39+ ABC` , 
40+  regex : / ^ A B C / m, 
41+  } , 
42+  dotAll : { 
43+  textToMatch : `AB 
44+ C` , 
45+  regex : / A B .C / s, 
46+  } , 
47+  unicode : { 
48+  textToMatch : '\u{61}' , 
49+  regex : / \u{61} / u, 
50+  } , 
51+  sticky : { 
52+  textToMatch : 'ABC' , 
53+  regex : / A B C / y, 
54+  } , 
55+  indecies : { 
56+  textToMatch : 'ABC ABC' , 
57+  // eslint-disable-next-line no-empty-character-class 
58+  regex : / A B C / d, 
59+  } , 
60+  } , 
61+ ) 
1762
18- // https://stackoverflow.com/questions/1520800/why-does-a-regexp-with-global-flag-give-wrong-results 
1963test ( 'matchers recreate regex to prevent global mistakes' ,  ( )  =>  { 
2064 const  regex  =  / A B C / g
2165 expect ( matches ( 'ABC' ,  node ,  regex ,  normalizer ) ) . toBe ( true ) 
0 commit comments