@@ -37,13 +37,39 @@ const mockRedisAclListResponse_2: string[] = [
37
37
const mockFTListResponse_1 = [ ] ;
38
38
const mockFTListResponse_2 = [ 'idx' ] ;
39
39
40
+ const generateRTSRecommendationTests = [
41
+ { input : [ '0' , [ '123' , 123 ] ] , expected : null } ,
42
+ { input : [ '0' , [ '1234567891' , 3 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
43
+ { input : [ '0' , [ '1234567891' , 1234567891 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
44
+ { input : [ '0' , [ '123' , 1234567891 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
45
+ { input : [ '0' , [ '123' , 12345678911 ] ] , expected : null } ,
46
+ { input : [ '0' , [ '123' , 1234567891234 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
47
+ { input : [ '0' , [ '123' , 12345678912345 ] ] , expected : null } ,
48
+ { input : [ '0' , [ '123' , 1234567891234567 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
49
+ { input : [ '0' , [ '12345678912345678' , 1 ] ] , expected : null } ,
50
+ { input : [ '0' , [ '1234567891234567891' , 1 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
51
+ { input : [ '0' , [ '1' , 1234567891.2 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
52
+ { input : [ '0' , [ '1234567891.2' , 1 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
53
+ { input : [ '0' , [ '1234567891:12' , 1 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
54
+ { input : [ '0' , [ '1234567891a12' , 1 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
55
+ { input : [ '0' , [ '1234567891.2.2' , 1 ] ] , expected : null } ,
56
+ { input : [ '0' , [ '1234567891asd' , 1 ] ] , expected : null } ,
57
+ { input : [ '0' , [ '10-10-2020' , 1 ] ] , expected : { name : RECOMMENDATION_NAMES . RTS } } ,
58
+ { input : [ '0' , [ '' , 1 ] ] , expected : null } ,
59
+ { input : [ '0' , [ '1' , - 12 ] ] , expected : null } ,
60
+ { input : [ '0' , [ '1' , - 1234567891 ] ] , expected : null } ,
61
+ { input : [ '0' , [ '1' , - 1234567891.123 ] ] , expected : null } ,
62
+ { input : [ '0' , [ '1' , - 1234567891.123 ] ] , expected : null } ,
63
+ { input : [ '0' , [ '1234567891.-123' , 1 ] ] , expected : null } ,
64
+ ] ;
65
+
40
66
const mockZScanResponse_1 = [
41
67
'0' ,
42
- [ 123456789 , 123456789 , 12345678910 , 12345678910 ] ,
68
+ [ '1' , 1 , ' 12345678910' , 12345678910 ] ,
43
69
] ;
44
70
const mockZScanResponse_2 = [
45
71
'0' ,
46
- [ 12345678910 , 12345678910 , 1 , 1 ] ,
72
+ [ ' 12345678910' , 12345678910 , 1 , 1 ] ,
47
73
] ;
48
74
49
75
const mockKeys = [
@@ -489,28 +515,14 @@ describe('RecommendationProvider', () => {
489
515
} ) ;
490
516
491
517
describe ( 'determineRTSRecommendation' , ( ) => {
492
- it ( 'should not return RTS recommendation ', async ( ) => {
518
+ test . each ( generateRTSRecommendationTests ) ( '%j ', async ( { input , expected } ) => {
493
519
when ( nodeClient . sendCommand )
494
520
. calledWith ( jasmine . objectContaining ( { name : 'zscan' } ) )
495
- . mockResolvedValue ( mockZScanResponse_1 ) ;
521
+ . mockResolvedValue ( input ) ;
496
522
497
523
const RTSRecommendation = await service
498
524
. determineRTSRecommendation ( nodeClient , mockKeys ) ;
499
- expect ( RTSRecommendation ) . toEqual ( null ) ;
500
- } ) ;
501
-
502
- it ( 'should return RTS recommendation' , async ( ) => {
503
- when ( nodeClient . sendCommand )
504
- . calledWith ( jasmine . objectContaining ( { name : 'zscan' } ) )
505
- . mockResolvedValueOnce ( mockZScanResponse_1 ) ;
506
-
507
- when ( nodeClient . sendCommand )
508
- . calledWith ( jasmine . objectContaining ( { name : 'zscan' } ) )
509
- . mockResolvedValue ( mockZScanResponse_2 ) ;
510
-
511
- const RTSRecommendation = await service
512
- . determineRTSRecommendation ( nodeClient , mockSortedSets ) ;
513
- expect ( RTSRecommendation ) . toEqual ( { name : RECOMMENDATION_NAMES . RTS } ) ;
525
+ expect ( RTSRecommendation ) . toEqual ( expected ) ;
514
526
} ) ;
515
527
516
528
it ( 'should not return RTS recommendation when only 101 sorted set contain timestamp' , async ( ) => {
0 commit comments