File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ test('matchers accept regex', () => {
15
15
expect ( fuzzyMatches ( 'ABC' , node , / A B C / , normalizer ) ) . toBe ( true )
16
16
} )
17
17
18
+ // https://stackoverflow.com/questions/1520800/why-does-a-regexp-with-global-flag-give-wrong-results
19
+ test ( 'matchers recreate regex to prevent global mistakes' , ( ) => {
20
+ const regex = / A B C / g
21
+ expect ( matches ( 'ABC' , node , regex , normalizer ) ) . toBe ( true )
22
+ // without recreation of the regexp this would be false
23
+ expect ( fuzzyMatches ( 'ABC' , node , regex , normalizer ) ) . toBe ( true )
24
+ } )
25
+
18
26
test ( 'matchers accept functions' , ( ) => {
19
27
expect ( matches ( 'ABC' , node , text => text === 'ABC' , normalizer ) ) . toBe ( true )
20
28
expect ( fuzzyMatches ( 'ABC' , node , text => text === 'ABC' , normalizer ) ) . toBe (
You can’t perform that action at this time.
0 commit comments