Skip to content

Commit aa9fbd7

Browse files
authoredApr 22, 2024
Merge pull request #19 from Mermaid-Chart/test/sdk/fix-typescript-error-in-e2e-tests
test(sdk): fix typescript error in tests
2 parents f8a1430 + c08fa9e commit aa9fbd7

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed
 

‎packages/sdk/src/index.test.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ import { AuthorizationData } from './types.js';
44

55
import { OAuth2Client } from '@badgateway/oauth2-client';
66

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+
721
describe('MermaidChart', () => {
822
let client: MermaidChart;
923
beforeEach(() => {
1024
vi.resetAllMocks();
1125

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);
2727

2828
client = new MermaidChart({
2929
clientID: '00000000-0000-0000-0000-000000000dead',

0 commit comments

Comments
 (0)
Failed to load comments.