@@ -29,27 +29,47 @@ describe('Kuzzle Login', function () {
2929    it ( 'should handle login with only the strategy' ,  function  ( done )  { 
3030      kuzzle . login ( 'local' ,  function ( )  { 
3131        should ( queryStub ) . be . calledOnce ( ) ; 
32+         should ( queryStub . firstCall ) . be . calledWith ( 
33+           { controller : 'auth' ,  action : 'login' } , 
34+           { body : { } ,  strategy : 'local' } , 
35+           { queuable : false } 
36+         ) ; 
3237        done ( ) ; 
3338      } ) ; 
3439    } ) ; 
3540
3641    it ( 'should handle login with credentials' ,  function  ( done )  { 
3742      kuzzle . login ( 'local' ,  loginCredentials ,  function ( )  { 
3843        should ( queryStub ) . be . calledOnce ( ) ; 
44+         should ( queryStub . firstCall ) . be . calledWith ( 
45+           { controller : 'auth' ,  action : 'login' } , 
46+           { body : { username : 'foo' ,  password : 'bar' } ,  strategy : 'local' } , 
47+           { queuable : false } 
48+         ) ; 
3949        done ( ) ; 
4050      } ) ; 
4151    } ) ; 
4252
4353    it ( 'should handle login without credentials and with expiresIn' ,  function  ( done )  { 
4454      kuzzle . login ( 'local' ,  '1h' ,  function ( )  { 
4555        should ( queryStub ) . be . calledOnce ( ) ; 
56+         should ( queryStub . firstCall ) . be . calledWith ( 
57+           { controller : 'auth' ,  action : 'login' } , 
58+           { body : { } ,  strategy : 'local' ,  expiresIn : '1h' } , 
59+           { queuable : false } 
60+         ) ; 
4661        done ( ) ; 
4762      } ) ; 
4863    } ) ; 
4964
5065    it ( 'should have the token in login callback' ,  function  ( done )  { 
5166      kuzzle . login ( 'local' ,  loginCredentials ,  '1h' ,  function ( )  { 
5267        should ( kuzzle . jwtToken ) . be . exactly ( 'test-toto' ) ; 
68+         should ( queryStub . firstCall ) . be . calledWith ( 
69+           { controller : 'auth' ,  action : 'login' } , 
70+           { body : { username : 'foo' ,  password : 'bar' } ,  strategy : 'local' ,  expiresIn : '1h' } , 
71+           { queuable : false } 
72+         ) ; 
5373        done ( ) ; 
5474      } ) ; 
5575    } ) ; 
@@ -65,29 +85,39 @@ describe('Kuzzle Login', function () {
6585    it ( 'should handle login with only the strategy' ,  function  ( )  { 
6686      kuzzle . login ( 'local' ) ; 
6787      should ( queryStub ) . be . calledOnce ( ) ; 
88+       should ( queryStub . firstCall ) . be . calledWith ( 
89+         { controller : 'auth' ,  action : 'login' } , 
90+         { body : { } ,  strategy : 'local' } , 
91+         { queuable : false } 
92+       ) ; 
6893    } ) ; 
6994
7095    it ( 'should handle login with credentials' ,  function  ( )  { 
7196      kuzzle . login ( 'local' ,  loginCredentials ) ; 
7297      should ( queryStub ) . be . calledOnce ( ) ; 
98+       should ( queryStub . firstCall ) . be . calledWith ( 
99+         { controller : 'auth' ,  action : 'login' } , 
100+         { body : { username : 'foo' ,  password : 'bar' } ,  strategy : 'local' } , 
101+         { queuable : false } 
102+       ) ; 
73103    } ) ; 
74104
75105    it ( 'should handle login without credentials and with expiresIn' ,  function  ( )  { 
76106      kuzzle . login ( 'local' ,  '1h' ) ; 
77107      should ( queryStub ) . be . calledOnce ( ) ; 
108+       should ( queryStub . firstCall ) . be . calledWith ( 
109+         { controller : 'auth' ,  action : 'login' } , 
110+         { body : { } ,  strategy : 'local' ,  expiresIn : '1h' } , 
111+         { queuable : false } 
112+       ) ; 
78113    } ) ; 
79114
80115    it ( 'should handle optional arguments correctly' ,  function  ( )  { 
81-       kuzzle . login ( 'local' ,  loginCredentials ) ; 
82116      kuzzle . login ( 'local' ,  loginCredentials ,  '1h' ) ; 
117+       should ( queryStub ) . be . calledOnce ( ) ; 
83118      should ( queryStub . firstCall ) . be . calledWith ( 
84119        { controller : 'auth' ,  action : 'login' } , 
85-         { strategy : 'local' ,  body : { username : 'foo' ,  password : 'bar' } } , 
86-         { queuable : false } 
87-       ) ; 
88-       should ( queryStub . secondCall ) . be . calledWith ( 
89-         { controller : 'auth' ,  action : 'login' } , 
90-         { strategy : 'local' ,  body : { username : 'foo' ,  password : 'bar' ,  expiresIn : '1h' } } , 
120+         { body : { username : 'foo' ,  password : 'bar' } ,  strategy : 'local' ,  expiresIn : '1h' } , 
91121        { queuable : false } 
92122      ) ; 
93123    } ) ; 
0 commit comments