Skip to content

Commit a3ad8bd

Browse files
Init test profile
1 parent b4b8131 commit a3ad8bd

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

tests/ProfileModule.test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { it } from "vitest";
2+
import { beforeEach } from "vitest";
3+
import { describe } from "vitest";
4+
import { expect } from "vitest";
5+
import { vi } from "vitest";
6+
7+
vi.mock('conf', () => {
8+
const Conf = vi.fn(() => ({
9+
get: vi.fn(),
10+
set: vi.fn(),
11+
clear: vi.fn(),
12+
}));
13+
return { default: Conf };
14+
});
15+
16+
let initProfileModule;
17+
let getProfileModule;
18+
19+
beforeEach(async () => {
20+
vi.resetModules();
21+
const module = await import('../src/modules/ProfileModule');
22+
initProfileModule = module.initProfileModule;
23+
getProfileModule = module.getProfileModule;
24+
});
25+
26+
describe("initProfileModule", () => {
27+
it("should initialize profile module", () => {
28+
initProfileModule();
29+
const profileModule = getProfileModule();
30+
expect(profileModule).toBeDefined();
31+
})
32+
})
33+
34+
describe('getProfileModule', () => {
35+
it('should return profile module if initialized', () => {
36+
initProfileModule();
37+
const result = getProfileModule();
38+
expect(result).toBeDefined();
39+
});
40+
41+
it('should throw error if not initialized', () => {
42+
expect(() => getProfileModule()).toThrow('Call initprofileModule() first');
43+
});
44+
});

0 commit comments

Comments
 (0)