@@ -18,13 +18,31 @@ describe('truncate()', () => {
1818} ) ;
1919
2020describe ( 'isMatchingPattern()' , ( ) => {
21- test ( 'match using string substring' , ( ) => {
21+ test ( 'match using string substring if `requireExactStringMatch` not given ' , ( ) => {
2222 expect ( isMatchingPattern ( 'foobar' , 'foobar' ) ) . toEqual ( true ) ;
2323 expect ( isMatchingPattern ( 'foobar' , 'foo' ) ) . toEqual ( true ) ;
2424 expect ( isMatchingPattern ( 'foobar' , 'bar' ) ) . toEqual ( true ) ;
2525 expect ( isMatchingPattern ( 'foobar' , 'nope' ) ) . toEqual ( false ) ;
2626 } ) ;
2727
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+
2846 test ( 'match using regexp test' , ( ) => {
2947 expect ( isMatchingPattern ( 'foobar' , / ^ f o o / ) ) . toEqual ( true ) ;
3048 expect ( isMatchingPattern ( 'foobar' , / f o o / ) ) . toEqual ( true ) ;
0 commit comments