@@ -15,7 +15,7 @@ describe('api', () => {
1515 const mtLinkSdk = new MtLinkSdk ( ) ;
1616 mtLinkSdk . init ( clientId , {
1717 redirectUri,
18- state
18+ state,
1919 } ) ;
2020
2121 test ( 'without calling init' , async ( ) => {
@@ -37,7 +37,7 @@ describe('api', () => {
3737 await expect (
3838 exchangeToken ( instance . storedOptions , {
3939 code,
40- state
40+ state,
4141 } )
4242 ) . rejects . toThrow (
4343 '[mt-link-sdk] Missing option `redirectUri` in `exchangeToken`, make sure to pass one via `exchangeToken` options or `init` options.'
@@ -63,14 +63,14 @@ describe('api', () => {
6363 expect ( fetch ) . toBeCalledWith ( url , {
6464 method : 'POST' ,
6565 headers : {
66- 'Content-Type' : 'application/json'
66+ 'Content-Type' : 'application/json' ,
6767 } ,
6868 body : JSON . stringify ( {
6969 code,
7070 client_id : clientId ,
7171 grant_type : 'authorization_code' ,
72- redirect_uri : redirectUri
73- } )
72+ redirect_uri : redirectUri ,
73+ } ) ,
7474 } ) ;
7575 } ) ;
7676
@@ -80,9 +80,9 @@ describe('api', () => {
8080 fetch . mockClear ( ) ;
8181 fetch . mockRejectedValueOnce ( error ) ;
8282
83- await expect ( exchangeToken ( mtLinkSdk . storedOptions , { code , state , redirectUri } ) ) . rejects . toThrow (
84- `[mt-link-sdk] \` exchangeToken\` execution failed. ${ error } `
85- ) ;
83+ await expect (
84+ exchangeToken ( mtLinkSdk . storedOptions , { code , state , redirectUri } )
85+ ) . rejects . toThrow ( `[mt-link-sdk] \`exchangeToken\` execution failed. ${ error } ` ) ;
8686 } ) ;
8787
8888 test ( 'throw error on response with error' , async ( ) => {
@@ -103,7 +103,7 @@ describe('api', () => {
103103 fetch . mockResponseOnce ( JSON . stringify ( { access_token : token } ) ) ;
104104
105105 jest . spyOn ( window , 'location' , 'get' ) . mockReturnValueOnce ( {
106- search : `?code=${ code1 } &code=${ code2 } `
106+ search : `?code=${ code1 } &code=${ code2 } ` ,
107107 } as typeof window . location ) ;
108108
109109 await exchangeToken ( mtLinkSdk . storedOptions , { state } ) ;
@@ -122,15 +122,17 @@ describe('api', () => {
122122 fetch . mockResponseOnce ( JSON . stringify ( { access_token : token } ) ) ;
123123
124124 jest . spyOn ( window , 'location' , 'get' ) . mockReturnValueOnce ( {
125- search : `?state=${ state1 } &state=${ state } `
125+ search : `?state=${ state1 } &state=${ state } ` ,
126126 } as typeof window . location ) ;
127127
128- await expect ( exchangeToken ( mtLinkSdk . storedOptions , { code, redirectUri } ) ) . resolves . toBe ( token ) ;
128+ await expect ( exchangeToken ( mtLinkSdk . storedOptions , { code, redirectUri } ) ) . resolves . toBe (
129+ token
130+ ) ;
129131 } ) ;
130132
131133 test ( 'non browser environment will not auto extract code from url' , async ( ) => {
132134 const windowSpy = jest . spyOn ( global , 'window' , 'get' ) ;
133- // @ts -ignore
135+ // @ts -ignore: mocking window object to undefined
134136 windowSpy . mockImplementation ( ( ) => undefined ) ;
135137
136138 await expect ( exchangeToken ( mtLinkSdk . storedOptions ) ) . rejects . toThrow (
0 commit comments