@@ -10,8 +10,10 @@ governing permissions and limitations under the License.
1010*/
1111
1212import { describe , test , expect , beforeEach , vi } from 'vitest'
13- import { getAccessTokenByClientCredentials , getAndValidateCredentials } from '../src/ims.js'
14- import { codes } from '../src/errors.js'
13+ import {
14+ getAccessTokenByClientCredentials ,
15+ getAndValidateCredentials
16+ } from '../src/ims.js'
1517
1618// Mock fetch globally
1719global . fetch = vi . fn ( )
@@ -205,7 +207,7 @@ describe('getAccessTokenByClientCredentials', () => {
205207
206208 await expect ( getAccessTokenByClientCredentials ( validParams ) )
207209 . rejects
208- . toThrow ( codes . IMS_TOKEN_ERROR )
210+ . toThrow ( ' IMS_TOKEN_ERROR' )
209211
210212 // Additional validation
211213 let error
@@ -234,7 +236,7 @@ describe('getAccessTokenByClientCredentials', () => {
234236
235237 await expect ( getAccessTokenByClientCredentials ( validParams ) )
236238 . rejects
237- . toThrow ( codes . IMS_TOKEN_ERROR )
239+ . toThrow ( ' IMS_TOKEN_ERROR' )
238240 } )
239241
240242 test ( 'throws IMS_TOKEN_ERROR with HTTP status when no error fields present' , async ( ) => {
@@ -257,15 +259,14 @@ describe('getAccessTokenByClientCredentials', () => {
257259 expect ( error . name ) . toBe ( 'AuthSDKError' )
258260 expect ( error . code ) . toBe ( 'IMS_TOKEN_ERROR' )
259261 expect ( error . message ) . toContain ( 'HTTP 503' )
260- expect ( error . sdkDetails . statusCode ) . toBe ( 503 )
261262 } )
262263
263264 test ( 'throws GENERIC_ERROR on network failure' , async ( ) => {
264265 fetch . mockRejectedValue ( new Error ( 'Network connection failed' ) )
265266
266267 await expect ( getAccessTokenByClientCredentials ( validParams ) )
267268 . rejects
268- . toThrow ( codes . GENERIC_ERROR )
269+ . toThrow ( ' GENERIC_ERROR' )
269270
270271 // Additional validation
271272 let error
@@ -284,7 +285,7 @@ describe('getAccessTokenByClientCredentials', () => {
284285
285286 await expect ( getAccessTokenByClientCredentials ( validParams ) )
286287 . rejects
287- . toThrow ( codes . GENERIC_ERROR )
288+ . toThrow ( ' GENERIC_ERROR' )
288289 } )
289290
290291 test ( 'includes sdkDetails in error for debugging' , async ( ) => {
@@ -302,7 +303,7 @@ describe('getAccessTokenByClientCredentials', () => {
302303
303304 await expect ( getAccessTokenByClientCredentials ( validParams ) )
304305 . rejects
305- . toThrow ( codes . IMS_TOKEN_ERROR )
306+ . toThrow ( ' IMS_TOKEN_ERROR' )
306307
307308 // Additional validation
308309 let error
@@ -431,7 +432,7 @@ describe('getAndValidateCredentials', () => {
431432
432433 test ( 'throws BAD_CREDENTIALS_FORMAT when params is null' , ( ) => {
433434 expect ( ( ) => getAndValidateCredentials ( null ) )
434- . toThrow ( codes . BAD_CREDENTIALS_FORMAT )
435+ . toThrow ( ' BAD_CREDENTIALS_FORMAT' )
435436
436437 let error
437438 try {
@@ -445,22 +446,22 @@ describe('getAndValidateCredentials', () => {
445446
446447 test ( 'throws BAD_CREDENTIALS_FORMAT when params is undefined' , ( ) => {
447448 expect ( ( ) => getAndValidateCredentials ( undefined ) )
448- . toThrow ( codes . BAD_CREDENTIALS_FORMAT )
449+ . toThrow ( ' BAD_CREDENTIALS_FORMAT' )
449450 } )
450451
451452 test ( 'throws BAD_CREDENTIALS_FORMAT when params is an array' , ( ) => {
452453 expect ( ( ) => getAndValidateCredentials ( [ 'test' ] ) )
453- . toThrow ( codes . BAD_CREDENTIALS_FORMAT )
454+ . toThrow ( ' BAD_CREDENTIALS_FORMAT' )
454455 } )
455456
456457 test ( 'throws BAD_CREDENTIALS_FORMAT when params is a string' , ( ) => {
457458 expect ( ( ) => getAndValidateCredentials ( 'test' ) )
458- . toThrow ( codes . BAD_CREDENTIALS_FORMAT )
459+ . toThrow ( ' BAD_CREDENTIALS_FORMAT' )
459460 } )
460461
461462 test ( 'throws BAD_CREDENTIALS_FORMAT when params is a number' , ( ) => {
462463 expect ( ( ) => getAndValidateCredentials ( 123 ) )
463- . toThrow ( codes . BAD_CREDENTIALS_FORMAT )
464+ . toThrow ( ' BAD_CREDENTIALS_FORMAT' )
464465 } )
465466
466467 test ( 'throws MISSING_PARAMETERS when clientId is missing' , ( ) => {
@@ -470,7 +471,7 @@ describe('getAndValidateCredentials', () => {
470471 }
471472
472473 expect ( ( ) => getAndValidateCredentials ( params ) )
473- . toThrow ( codes . MISSING_PARAMETERS )
474+ . toThrow ( ' MISSING_PARAMETERS' )
474475 } )
475476
476477 test ( 'throws MISSING_PARAMETERS when clientSecret is missing' , ( ) => {
@@ -480,7 +481,7 @@ describe('getAndValidateCredentials', () => {
480481 }
481482
482483 expect ( ( ) => getAndValidateCredentials ( params ) )
483- . toThrow ( codes . MISSING_PARAMETERS )
484+ . toThrow ( ' MISSING_PARAMETERS' )
484485 } )
485486
486487 test ( 'throws MISSING_PARAMETERS when orgId is missing' , ( ) => {
@@ -490,7 +491,7 @@ describe('getAndValidateCredentials', () => {
490491 }
491492
492493 expect ( ( ) => getAndValidateCredentials ( params ) )
493- . toThrow ( codes . MISSING_PARAMETERS )
494+ . toThrow ( ' MISSING_PARAMETERS' )
494495 } )
495496
496497 test ( 'throws MISSING_PARAMETERS with all missing params listed' , ( ) => {
@@ -517,7 +518,7 @@ describe('getAndValidateCredentials', () => {
517518 }
518519
519520 expect ( ( ) => getAndValidateCredentials ( params ) )
520- . toThrow ( codes . BAD_SCOPES_FORMAT )
521+ . toThrow ( ' BAD_SCOPES_FORMAT' )
521522
522523 let error
523524 try {
@@ -539,7 +540,7 @@ describe('getAndValidateCredentials', () => {
539540 }
540541
541542 expect ( ( ) => getAndValidateCredentials ( params ) )
542- . toThrow ( codes . BAD_SCOPES_FORMAT )
543+ . toThrow ( ' BAD_SCOPES_FORMAT' )
543544 } )
544545
545546 test ( 'throws BAD_SCOPES_FORMAT when scopes is a number' , ( ) => {
@@ -551,7 +552,7 @@ describe('getAndValidateCredentials', () => {
551552 }
552553
553554 expect ( ( ) => getAndValidateCredentials ( params ) )
554- . toThrow ( codes . BAD_SCOPES_FORMAT )
555+ . toThrow ( ' BAD_SCOPES_FORMAT' )
555556 } )
556557
557558 test ( 'accepts scopes as an array' , ( ) => {
0 commit comments