Skip to content

Commit

Permalink
Reverte changes x2
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhenjaHorbach committed May 16, 2024
1 parent 39c9d9b commit 3a9a1a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions tests/actions/PolicyTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ describe('actions/Policy', () => {
});
});

let mockFetch: MockFetch;
beforeEach(() => {
mockFetch = TestHelper.getGlobalFetchMock() as MockFetch;
global.fetch = TestHelper.getGlobalFetchMock();
return Onyx.clear().then(waitForBatchedUpdates);
});

describe('createWorkspace', () => {
it('creates a new workspace', async () => {
mockFetch?.pause?.();
(fetch as MockFetch)?.pause?.();
Onyx.set(ONYXKEYS.SESSION, {email: ESH_EMAIL, accountID: ESH_ACCOUNT_ID});
await waitForBatchedUpdates();

Expand Down Expand Up @@ -124,7 +123,7 @@ describe('actions/Policy', () => {
});

// Check for success data
mockFetch?.resume?.();
(fetch as MockFetch)?.resume?.();
await waitForBatchedUpdates();

policy = await new Promise((resolve) => {
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/TestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ function getGlobalFetchMock() {
json: () => Promise.resolve({jsonCode: 200}),
};

const mockFetch = jest.fn().mockImplementation(() => {
const mockFetch: MockFetch = jest.fn().mockImplementation(() => {
if (!isPaused) {
return Promise.resolve(getResponse());
}
return new Promise((resolve) => {
queue.push(resolve);
});
}) as MockFetch;
});

mockFetch.pause = () => (isPaused = true);
mockFetch.resume = () => {
Expand Down

0 comments on commit 3a9a1a5

Please sign in to comment.