File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments