Skip to content

Commit 3429a92

Browse files
committed
A bit of test cleanup
1 parent 7964dde commit 3429a92

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

packages/sdk/jest.setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
const fetchMock = require("jest-fetch-mock");
22
fetchMock.enableMocks();
33
global.fetch = fetchMock;
4+
5+
jest.mock("simple-oauth2");

packages/sdk/src/server/__tests__/server.test.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import fetchMock from "jest-fetch-mock";
2-
32
import { ClientCredentials } from "simple-oauth2";
4-
jest.mock("simple-oauth2");
53

64
import {
75
BackendClient,
@@ -687,29 +685,6 @@ describe("BackendClient", () => {
687685
let client: BackendClient;
688686

689687
beforeEach(() => {
690-
fetchMock.resetMocks();
691-
// These mocks are distinct from the ones in the outer beforeEach
692-
// We need to test the behavior of the client when the OAuth token
693-
// is expired or invalid
694-
const expiredTokenMock = {
695-
token: {
696-
access_token: "expired-oauth-token",
697-
},
698-
expired: jest.fn().mockReturnValue(true),
699-
};
700-
701-
const newTokenMock = {
702-
token: {
703-
access_token: "new-oauth-token",
704-
},
705-
expired: jest.fn().mockReturnValue(false),
706-
};
707-
708-
const getTokenMock = jest
709-
.fn()
710-
.mockResolvedValueOnce(expiredTokenMock)
711-
.mockResolvedValueOnce(newTokenMock);
712-
713688
client = new BackendClient(
714689
{
715690
credentials: {
@@ -721,11 +696,6 @@ describe("BackendClient", () => {
721696
);
722697
});
723698

724-
afterEach(() => {
725-
fetchMock.resetMocks();
726-
jest.clearAllMocks();
727-
});
728-
729699
it("should include externalUserId and environment headers", async () => {
730700
fetchMock.mockResponseOnce(
731701
JSON.stringify({

0 commit comments

Comments
 (0)