1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -4,26 +4,26 @@ import { AuthorizationData } from './types.js';
4
4
5
5
import { OAuth2Client } from '@badgateway/oauth2-client' ;
6
6
7
+ const mockOAuth2ClientRequest = ( async ( endpoint , _body ) => {
8
+ switch ( endpoint ) {
9
+ case 'tokenEndpoint' :
10
+ return {
11
+ access_token : 'test-example-access_token' ,
12
+ refresh_token : 'test-example-refresh_token' ,
13
+ token_type : 'Bearer' ,
14
+ expires_in : 3600 ,
15
+ } ;
16
+ default :
17
+ throw new Error ( 'mock unimplemented' ) ;
18
+ }
19
+ } ) as typeof OAuth2Client . prototype . request ;
20
+
7
21
describe ( 'MermaidChart' , ( ) => {
8
22
let client : MermaidChart ;
9
23
beforeEach ( ( ) => {
10
24
vi . resetAllMocks ( ) ;
11
25
12
- vi . spyOn ( OAuth2Client . prototype , 'request' ) . mockImplementation (
13
- async ( endpoint : 'tokenEndpoint' | 'introspectionEndpoint' , _body : Record < string , any > ) => {
14
- switch ( endpoint ) {
15
- case 'tokenEndpoint' :
16
- return {
17
- access_token : 'test-example-access_token' ,
18
- refresh_token : 'test-example-refresh_token' ,
19
- token_type : 'Bearer' ,
20
- expires_in : 3600 ,
21
- } ;
22
- default :
23
- throw new Error ( 'mock unimplemented' ) ;
24
- }
25
- } ,
26
- ) ;
26
+ vi . spyOn ( OAuth2Client . prototype , 'request' ) . mockImplementation ( mockOAuth2ClientRequest ) ;
27
27
28
28
client = new MermaidChart ( {
29
29
clientID : '00000000-0000-0000-0000-000000000dead' ,
0 commit comments