@@ -55,13 +55,30 @@ describe('redis-commands', function () {
55
55
expect ( commands . hasFlag ( 'select' , 'denyoom' ) ) . to . eql ( false ) ;
56
56
expect ( commands . hasFlag ( 'quit' , 'denyoom' ) ) . to . eql ( false ) ;
57
57
} ) ;
58
+
59
+ it ( 'should throw on unknown commands' , function ( ) {
60
+ expect ( function ( ) { commands . hasFlag ( 'UNKNOWN' ) ; } ) . to . throw ( Error ) ;
61
+ } ) ;
58
62
} ) ;
59
63
60
64
describe ( '.getKeyIndexes()' , function ( ) {
61
65
var index = commands . getKeyIndexes ;
62
66
67
+ it ( 'should throw on unknown commands' , function ( ) {
68
+ expect ( function ( ) { index ( 'UNKNOWN' ) ; } ) . to . throw ( Error ) ;
69
+ } ) ;
70
+
71
+ it ( 'should throw on faulty args' , function ( ) {
72
+ expect ( function ( ) { index ( 'get' , 'foo' ) ; } ) . to . throw ( Error ) ;
73
+ } ) ;
74
+
75
+ it ( 'should return an empty array if no keys exist' , function ( ) {
76
+ expect ( index ( 'auth' , [ ] ) ) . to . eql ( [ ] ) ;
77
+ } ) ;
78
+
63
79
it ( 'should return key indexes' , function ( ) {
64
80
expect ( index ( 'set' , [ 'foo' , 'bar' ] ) ) . to . eql ( [ 0 ] ) ;
81
+ expect ( index ( 'del' , [ 'foo' ] ) ) . to . eql ( [ 0 ] ) ;
65
82
expect ( index ( 'get' , [ 'foo' ] ) ) . to . eql ( [ 0 ] ) ;
66
83
expect ( index ( 'mget' , [ 'foo' , 'bar' ] ) ) . to . eql ( [ 0 , 1 ] ) ;
67
84
expect ( index ( 'mset' , [ 'foo' , 'v1' , 'bar' , 'v2' ] ) ) . to . eql ( [ 0 , 2 ] ) ;
@@ -70,6 +87,9 @@ describe('redis-commands', function () {
70
87
expect ( index ( 'evalsha' , [ '23123' , '2' , 'foo' , 'bar' , 'zoo' ] ) ) . to . eql ( [ 2 , 3 ] ) ;
71
88
expect ( index ( 'sort' , [ 'key' ] ) ) . to . eql ( [ 0 ] ) ;
72
89
expect ( index ( 'zunionstore' , [ 'out' , '2' , 'zset1' , 'zset2' , 'WEIGHTS' , '2' , '3' ] ) ) . to . eql ( [ 0 , 2 , 3 ] ) ;
90
+ expect ( index ( 'migrate' , [ '127.0.0.1' , 6379 , 'foo' , 0 , 0 , 'COPY' ] ) ) . to . eql ( [ 2 ] ) ;
91
+ expect ( index ( 'migrate' , [ '127.0.0.1' , 6379 , '' , 0 , 0 , 'REPLACE' , 'KEYS' , 'foo' , 'bar' ] ) ) . to . eql ( [ 7 , 8 ] ) ;
92
+ expect ( index ( 'migrate' , [ '127.0.0.1' , 6379 , '' , 0 , 0 , 'KEYS' , 'foo' , 'bar' ] ) ) . to . eql ( [ 6 , 7 ] ) ;
73
93
} ) ;
74
94
75
95
it ( 'should support numeric argument' , function ( ) {
@@ -89,7 +109,7 @@ describe('redis-commands', function () {
89
109
expect ( index ( 'sort' , [ 'key' , 'BY' , 'hash:*->field' ] , {
90
110
parseExternalKey : true
91
111
} ) ) . to . eql ( [ 0 , [ 2 , 6 ] ] ) ;
92
- expect ( index ( 'sort' , [ 'key' , 'BY' , 'hash:*->field' , 'LIMIT' , 2 , 3 , 'GET' , 'gk' , 'GET' , '#' , 'Get' , 'gh->f*' , 'DESC' , 'ALPHA' , 'STORE' , 'store' ] , {
112
+ expect ( index ( 'sort' , [ 'key' , 'BY' , 'hash:*->field' , 'LIMIT' , 2 , 3 , 'GET' , new Buffer ( 'gk' ) , 'GET' , '#' , 'Get' , 'gh->f*' , 'DESC' , 'ALPHA' , 'STORE' , 'store' ] , {
93
113
parseExternalKey : true
94
114
} ) ) . to . eql ( [ 0 , [ 2 , 6 ] , [ 7 , 2 ] , [ 11 , 2 ] , 15 ] ) ;
95
115
} ) ;
0 commit comments