@@ -89,12 +89,16 @@ describe('LinkedInAdapter', function () {
8989
9090  describe ( 'Test getUserFromAccessToken' ,  function  ( )  { 
9191    it ( 'should fetch user successfully' ,  async  function  ( )  { 
92-       global . fetch  =  jasmine . createSpy ( ) . and . returnValue ( 
93-         Promise . resolve ( { 
94-           ok : true , 
95-           json : ( )  =>  Promise . resolve ( {  id : 'validUserId'  } ) , 
96-         } ) 
97-       ) ; 
92+       mockFetch ( [ 
93+         { 
94+           url : 'https://api.linkedin.com/v2/me' , 
95+           method : 'GET' , 
96+           response : { 
97+             ok : true , 
98+             json : ( )  =>  Promise . resolve ( {  id : 'validUserId'  } ) , 
99+           } , 
100+         } , 
101+       ] ) ; 
98102
99103      const  user  =  await  adapter . getUserFromAccessToken ( 'validToken' ,  false ) ; 
100104
@@ -104,14 +108,21 @@ describe('LinkedInAdapter', function () {
104108          'x-li-format' : 'json' , 
105109          'x-li-src' : undefined , 
106110        } , 
111+         method : 'GET' , 
107112      } ) ; 
108113      expect ( user ) . toEqual ( {  id : 'validUserId'  } ) ; 
109114    } ) ; 
110115
111116    it ( 'should throw error for invalid response' ,  async  function  ( )  { 
112-       global . fetch  =  jasmine . createSpy ( ) . and . returnValue ( 
113-         Promise . resolve ( {  ok : false  } ) 
114-       ) ; 
117+       mockFetch ( [ 
118+         { 
119+           url : 'https://api.linkedin.com/v2/me' , 
120+           method : 'GET' , 
121+           response : { 
122+             ok : false , 
123+           } , 
124+         } , 
125+       ] ) ; 
115126
116127      await  expectAsync ( adapter . getUserFromAccessToken ( 'invalidToken' ,  false ) ) . toBeRejectedWith ( 
117128        new  Error ( 'LinkedIn API request failed.' ) 
@@ -121,12 +132,16 @@ describe('LinkedInAdapter', function () {
121132
122133  describe ( 'Test getAccessTokenFromCode' ,  function  ( )  { 
123134    it ( 'should fetch token successfully' ,  async  function  ( )  { 
124-       global . fetch  =  jasmine . createSpy ( ) . and . returnValue ( 
125-         Promise . resolve ( { 
126-           ok : true , 
127-           json : ( )  =>  Promise . resolve ( {  access_token : 'validToken'  } ) , 
128-         } ) 
129-       ) ; 
135+       mockFetch ( [ 
136+         { 
137+           url : 'https://www.linkedin.com/oauth/v2/accessToken' , 
138+           method : 'POST' , 
139+           response : { 
140+             ok : true , 
141+             json : ( )  =>  Promise . resolve ( {  access_token : 'validToken'  } ) , 
142+           } , 
143+         } , 
144+       ] ) ; 
130145
131146      const  tokenResponse  =  await  adapter . getAccessTokenFromCode ( 'validCode' ,  'http://example.com' ) ; 
132147
@@ -139,9 +154,15 @@ describe('LinkedInAdapter', function () {
139154    } ) ; 
140155
141156    it ( 'should throw error for invalid response' ,  async  function  ( )  { 
142-       global . fetch  =  jasmine . createSpy ( ) . and . returnValue ( 
143-         Promise . resolve ( {  ok : false  } ) 
144-       ) ; 
157+       mockFetch ( [ 
158+         { 
159+           url : 'https://www.linkedin.com/oauth/v2/accessToken' , 
160+           method : 'POST' , 
161+           response : { 
162+             ok : false , 
163+           } , 
164+         } , 
165+       ] ) ; 
145166
146167      await  expectAsync ( 
147168        adapter . getAccessTokenFromCode ( 'invalidCode' ,  'http://example.com' ) 
0 commit comments