Skip to content

Commit 18a4890

Browse files
committed
Mock everywhere with the same style
1 parent 44c7e3b commit 18a4890

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

packages/dashboard-frontend/tests/services/remote-cached-data-provider.test.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from "@jest/globals";
1+
import { beforeEach, describe, expect, it } from "@jest/globals";
22
import { fetchJson } from "../../src/fetch/fetch-json";
33
import { getItem, setItem } from "../../src/services/cache";
44
import { RemoteCachedDataProvider } from "../../src/services/remote-cached-data-provider";
@@ -7,17 +7,13 @@ jest.mock( "../../src/services/cache", () => ( {
77
getItem: jest.fn(),
88
setItem: jest.fn(),
99
} ) );
10-
jest.mock( "../../src/fetch/fetch-json" );
10+
jest.mock( "../../src/fetch/fetch-json", () => ( {
11+
fetchJson: jest.fn().mockImplementation( () => Promise.resolve( "result" ) ),
12+
} ) );
1113

1214
describe( "RemoteCachedDataProvider", () => {
13-
beforeAll( () => {
14-
fetchJson.mockImplementation( () => {
15-
return Promise.resolve( "result" );
16-
} );
17-
} );
18-
19-
beforeEach( () => {
20-
fetchJson.mockClear();
15+
afterEach( () => {
16+
jest.clearAllMocks();
2117
} );
2218

2319
test.each( [

0 commit comments

Comments
 (0)