@@ -335,11 +335,37 @@ describe('ParticleAPI', () => {
335335 } ) ;
336336
337337 describe ( '.listAccessTokens' , ( ) => {
338+ let options ;
339+
340+ beforeEach ( ( ) => {
341+ options = {
342+ username : props . username ,
343+ password : props . password ,
344+ otp : props . otp
345+ } ;
346+ } ) ;
347+
338348 it ( 'sends credentials' , ( ) => {
339- return api . listAccessTokens ( props ) . then ( ( { auth } ) => {
340- auth . username . should . equal ( props . username ) ;
341- auth . password . should . equal ( props . password ) ;
342- } ) ;
349+ delete options . otp ;
350+ return api . listAccessTokens ( options )
351+ . then ( ( { auth, query } ) => {
352+ expect ( auth ) . to . be . an ( 'object' ) ;
353+ expect ( auth ) . to . have . property ( 'username' , options . username ) ;
354+ expect ( auth ) . to . have . property ( 'password' , options . password ) ;
355+ expect ( query ) . to . equal ( undefined ) ;
356+ } ) ;
357+ } ) ;
358+
359+ it ( 'includes otp when provided' , ( ) => {
360+ return api . listAccessTokens ( options )
361+ . then ( ( { auth, query } ) => {
362+ expect ( auth ) . to . be . an ( 'object' ) ;
363+ expect ( auth ) . to . have . property ( 'username' , options . username ) ;
364+ expect ( auth ) . to . have . property ( 'password' , options . password ) ;
365+ expect ( query ) . to . be . an ( 'object' ) ;
366+ expect ( query ) . to . have . property ( 'otp' , props . otp ) ;
367+ expect ( props . otp ) . to . be . a ( 'string' ) . with . lengthOf ( 6 ) ;
368+ } ) ;
343369 } ) ;
344370 } ) ;
345371
0 commit comments