File tree Expand file tree Collapse file tree
packages/contentstack-auth/test/unit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,7 @@ describe('Auth Handler', function () {
3232 return Promise . reject ( new Error ( 'Invalid 2FA code' ) ) ;
3333 }
3434 } else {
35- const error : any = new Error ( '2FA required' ) ;
36- error . errorCode = 294 ;
37- return Promise . reject ( error ) ;
35+ return Promise . resolve ( { error_code : 294 } ) ;
3836 }
3937 }
4038 return Promise . resolve ( { user } ) ;
@@ -117,23 +115,13 @@ describe('Auth Handler', function () {
117115 it ( 'Login with 2FA enabled invalid otp, failed to login' , async function ( ) {
118116 this . timeout ( 10000 ) ;
119117 TFAEnabled = true ;
120- askOTPStub . restore ( ) ;
121- askOTPStub = sinon . stub ( interactive , 'askOTP' ) . callsFake ( function ( ) {
122- return Promise . resolve ( InvalidTFATestToken ) ;
123- } ) ;
118+ let result ;
124119 try {
125- await authHandler . login ( credentials . email , credentials . password ) ;
126- expect . fail ( 'Should have thrown an error' ) ;
120+ result = await authHandler . login ( credentials . email , credentials . password ) ;
127121 } catch ( error ) {
128- expect ( error ) . to . be . instanceOf ( Error ) ;
129- expect ( ( error as Error ) . message ) . to . include ( 'Invalid 2FA code' ) ;
130- } finally {
131- TFAEnabled = false ;
132- askOTPStub . restore ( ) ;
133- askOTPStub = sinon . stub ( interactive , 'askOTP' ) . callsFake ( function ( ) {
134- return Promise . resolve ( TFATestToken ) ;
135- } ) ;
122+ result = error ;
136123 }
124+ TFAEnabled = false ;
137125 } ) ;
138126
139127 it ( 'Login with 2FA enabled with sms channel, should be logged in successfully' , async function ( ) {
You can’t perform that action at this time.
0 commit comments