@@ -374,4 +374,79 @@ describe('Processing strategy: DATE', () => {
374374 assert . isTrue ( result ) ;
375375 } )
376376
377+ } )
378+
379+ describe ( 'Processing strategy: REGEX' , ( ) => {
380+ const mock_values1 = [
381+ '\\bUSER_[0-9]{1,2}\\b'
382+ ] ;
383+
384+ const mock_values2 = [
385+ '\\bUSER_[0-9]{1,2}\\b' , '\\buser-[0-9]{1,2}\\b'
386+ ] ;
387+
388+ const mock_values3 = [
389+ 'USER_[0-9]{1,2}'
390+ ] ;
391+
392+ it ( 'UNIT_STRATEGY_SUITE - Should agree when expect to exist using EXIST operation' , ( ) => {
393+ let result = processOperation (
394+ StrategiesType . REGEX , OperationsType . EXIST , 'USER_1' , mock_values1 ) ;
395+ assert . isTrue ( result ) ;
396+
397+ result = processOperation (
398+ StrategiesType . REGEX , OperationsType . EXIST , 'user-01' , mock_values2 ) ;
399+ assert . isTrue ( result ) ;
400+ } )
401+
402+ it ( 'UNIT_STRATEGY_SUITE - Should NOT agree when expect to exist using EXIST operation' , ( ) => {
403+ let result = processOperation (
404+ StrategiesType . REGEX , OperationsType . EXIST , 'USER_123' , mock_values1 ) ;
405+ assert . isFalse ( result ) ;
406+
407+ //mock_values3 does not require exact match
408+ result = processOperation (
409+ StrategiesType . REGEX , OperationsType . EXIST , 'USER_123' , mock_values3 ) ;
410+ assert . isTrue ( result ) ;
411+ } )
412+
413+ it ( 'UNIT_STRATEGY_SUITE - Should agree when expect to not exist using NOT_EXIST operation' , ( ) => {
414+ let result = processOperation (
415+ StrategiesType . REGEX , OperationsType . NOT_EXIST , 'USER_123' , mock_values1 ) ;
416+ assert . isTrue ( result ) ;
417+
418+ result = processOperation (
419+ StrategiesType . REGEX , OperationsType . NOT_EXIST , 'user-123' , mock_values2 ) ;
420+ assert . isTrue ( result ) ;
421+ } )
422+
423+ it ( 'UNIT_STRATEGY_SUITE - Should NOT agree when expect to not exist using NOT_EXIST operation' , ( ) => {
424+ const result = processOperation (
425+ StrategiesType . REGEX , OperationsType . NOT_EXIST , 'USER_12' , mock_values1 ) ;
426+ assert . isFalse ( result ) ;
427+ } )
428+
429+ it ( 'UNIT_STRATEGY_SUITE - Should agree when expect to be equal using EQUAL operation' , ( ) => {
430+ const result = processOperation (
431+ StrategiesType . REGEX , OperationsType . EQUAL , 'USER_11' , mock_values3 ) ;
432+ assert . isTrue ( result ) ;
433+ } )
434+
435+ it ( 'UNIT_STRATEGY_SUITE - Should NOT agree when expect to be equal using EQUAL operation' , ( ) => {
436+ const result = processOperation (
437+ StrategiesType . REGEX , OperationsType . EQUAL , 'user-11' , mock_values3 ) ;
438+ assert . isFalse ( result ) ;
439+ } )
440+
441+ it ( 'UNIT_STRATEGY_SUITE - Should agree when expect to not be equal using NOT_EQUAL operation' , ( ) => {
442+ const result = processOperation (
443+ StrategiesType . REGEX , OperationsType . NOT_EQUAL , 'USER_123' , mock_values3 ) ;
444+ assert . isTrue ( result ) ;
445+ } )
446+
447+ it ( 'UNIT_STRATEGY_SUITE - Should NOT agree when expect to not be equal using NOT_EQUAL operation' , ( ) => {
448+ const result = processOperation (
449+ StrategiesType . REGEX , OperationsType . NOT_EQUAL , 'USER_1' , mock_values3 ) ;
450+ assert . isFalse ( result ) ;
451+ } )
377452} )
0 commit comments