@@ -18,13 +18,31 @@ describe('truncate()', () => {
18
18
} ) ;
19
19
20
20
describe ( 'isMatchingPattern()' , ( ) => {
21
- test ( 'match using string substring' , ( ) => {
21
+ test ( 'match using string substring if `requireExactStringMatch` not given ' , ( ) => {
22
22
expect ( isMatchingPattern ( 'foobar' , 'foobar' ) ) . toEqual ( true ) ;
23
23
expect ( isMatchingPattern ( 'foobar' , 'foo' ) ) . toEqual ( true ) ;
24
24
expect ( isMatchingPattern ( 'foobar' , 'bar' ) ) . toEqual ( true ) ;
25
25
expect ( isMatchingPattern ( 'foobar' , 'nope' ) ) . toEqual ( false ) ;
26
26
} ) ;
27
27
28
+ test ( 'match using string substring if `requireExactStringMatch` is `false`' , ( ) => {
29
+ expect ( isMatchingPattern ( 'foobar' , 'foobar' , false ) ) . toEqual ( true ) ;
30
+ expect ( isMatchingPattern ( 'foobar' , 'foo' , false ) ) . toEqual ( true ) ;
31
+ expect ( isMatchingPattern ( 'foobar' , 'bar' , false ) ) . toEqual ( true ) ;
32
+ expect ( isMatchingPattern ( 'foobar' , 'nope' , false ) ) . toEqual ( false ) ;
33
+ } ) ;
34
+
35
+ test ( 'match using exact string match if `requireExactStringMatch` is `true`' , ( ) => {
36
+ expect ( isMatchingPattern ( 'foobar' , 'foobar' , true ) ) . toEqual ( true ) ;
37
+ expect ( isMatchingPattern ( 'foobar' , 'foo' , true ) ) . toEqual ( false ) ;
38
+ expect ( isMatchingPattern ( 'foobar' , 'nope' , true ) ) . toEqual ( false ) ;
39
+ } ) ;
40
+
41
+ test ( 'matches when `value` constains `pattern` but not vice-versa' , ( ) => {
42
+ expect ( isMatchingPattern ( 'foobar' , 'foo' ) ) . toEqual ( true ) ;
43
+ expect ( isMatchingPattern ( 'foobar' , 'foobarbaz' ) ) . toEqual ( false ) ;
44
+ } ) ;
45
+
28
46
test ( 'match using regexp test' , ( ) => {
29
47
expect ( isMatchingPattern ( 'foobar' , / ^ f o o / ) ) . toEqual ( true ) ;
30
48
expect ( isMatchingPattern ( 'foobar' , / f o o / ) ) . toEqual ( true ) ;
0 commit comments