Skip to content

Commit 5a2d1c0

Browse files
committed
feat(dynamicImport): doMock and dynamic imports
1 parent cf344de commit 5a2d1c0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { getMockBohne } from "@/test/mockData";
2+
import { describe, expect, it, vitest } from "vitest";
3+
4+
const predictedPrice = 42;
5+
6+
vitest.doMock("@papperlapappyt/papperlapapp-coffee-prediction", () => ({
7+
predictPrice: vitest.fn().mockReturnValue(predictedPrice),
8+
}));
9+
const { calculate } = await import("@/state/calculate");
10+
11+
describe("tests dynamic import: predicted price returns 42", () => {
12+
describe("calculate", () => {
13+
it("should return the predictedVKP", () => {
14+
const bohne = getMockBohne();
15+
expect(calculate(bohne).predictedVKP).toEqual(predictedPrice);
16+
});
17+
});
18+
});
19+
export {};

0 commit comments

Comments
 (0)