@@ -55,13 +55,30 @@ describe('redis-commands', function () {
5555 expect ( commands . hasFlag ( 'select' , 'denyoom' ) ) . to . eql ( false ) ;
5656 expect ( commands . hasFlag ( 'quit' , 'denyoom' ) ) . to . eql ( false ) ;
5757 } ) ;
58+
59+ it ( 'should throw on unknown commands' , function ( ) {
60+ expect ( function ( ) { commands . hasFlag ( 'UNKNOWN' ) ; } ) . to . throw ( Error ) ;
61+ } ) ;
5862 } ) ;
5963
6064 describe ( '.getKeyIndexes()' , function ( ) {
6165 var index = commands . getKeyIndexes ;
6266
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+
6379 it ( 'should return key indexes' , function ( ) {
6480 expect ( index ( 'set' , [ 'foo' , 'bar' ] ) ) . to . eql ( [ 0 ] ) ;
81+ expect ( index ( 'del' , [ 'foo' ] ) ) . to . eql ( [ 0 ] ) ;
6582 expect ( index ( 'get' , [ 'foo' ] ) ) . to . eql ( [ 0 ] ) ;
6683 expect ( index ( 'mget' , [ 'foo' , 'bar' ] ) ) . to . eql ( [ 0 , 1 ] ) ;
6784 expect ( index ( 'mset' , [ 'foo' , 'v1' , 'bar' , 'v2' ] ) ) . to . eql ( [ 0 , 2 ] ) ;
@@ -70,6 +87,9 @@ describe('redis-commands', function () {
7087 expect ( index ( 'evalsha' , [ '23123' , '2' , 'foo' , 'bar' , 'zoo' ] ) ) . to . eql ( [ 2 , 3 ] ) ;
7188 expect ( index ( 'sort' , [ 'key' ] ) ) . to . eql ( [ 0 ] ) ;
7289 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 ] ) ;
7393 } ) ;
7494
7595 it ( 'should support numeric argument' , function ( ) {
@@ -89,7 +109,7 @@ describe('redis-commands', function () {
89109 expect ( index ( 'sort' , [ 'key' , 'BY' , 'hash:*->field' ] , {
90110 parseExternalKey : true
91111 } ) ) . 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' ] , {
93113 parseExternalKey : true
94114 } ) ) . to . eql ( [ 0 , [ 2 , 6 ] , [ 7 , 2 ] , [ 11 , 2 ] , 15 ] ) ;
95115 } ) ;
0 commit comments