File tree Expand file tree Collapse file tree 6 files changed +15
-43
lines changed Expand file tree Collapse file tree 6 files changed +15
-43
lines changed Original file line number Diff line number Diff line change @@ -39,15 +39,11 @@ export const mockKeystoreFindForKey = jest.fn(
39
39
) ;
40
40
41
41
jest . mock ( '../../../src/database/repository/UserRepo' , ( ) => ( {
42
- get findById ( ) {
43
- return mockUserFindById ;
44
- } ,
42
+ findById : mockUserFindById ,
45
43
} ) ) ;
46
44
47
45
jest . mock ( '../../../src/database/repository/KeystoreRepo' , ( ) => ( {
48
- get findforKey ( ) {
49
- return mockKeystoreFindForKey ;
50
- } ,
46
+ findforKey : mockKeystoreFindForKey ,
51
47
} ) ) ;
52
48
53
49
JWT . validate = mockJwtValidate ;
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ export const mockRoleRepoFindByCode = jest.fn(async (code: string): Promise<Role
68
68
} ) ;
69
69
70
70
export const mockJwtValidate = jest . fn ( async ( token : string ) : Promise < JwtPayload > => {
71
- let subject = null ;
71
+ let subject : null | string = null ;
72
72
switch ( token ) {
73
73
case ACCESS_TOKEN :
74
74
subject = USER_ID . toHexString ( ) ;
@@ -93,15 +93,11 @@ export const mockJwtValidate = jest.fn(async (token: string): Promise<JwtPayload
93
93
} ) ;
94
94
95
95
jest . mock ( '../../../src/database/repository/UserRepo' , ( ) => ( {
96
- get findById ( ) {
97
- return mockUserFindById ;
98
- } ,
96
+ findById : mockUserFindById ,
99
97
} ) ) ;
100
98
101
99
jest . mock ( '../../../src/database/repository/RoleRepo' , ( ) => ( {
102
- get findByCode ( ) {
103
- return mockRoleRepoFindByCode ;
104
- } ,
100
+ findByCode : mockRoleRepoFindByCode ,
105
101
} ) ) ;
106
102
107
103
JWT . validate = mockJwtValidate ;
Original file line number Diff line number Diff line change @@ -27,10 +27,6 @@ export const mockFindInfoWithTextById = jest.fn(
27
27
) ;
28
28
29
29
jest . mock ( '../../../../../src/database/repository/BlogRepo' , ( ) => ( {
30
- get findByUrl ( ) {
31
- return mockBlogFindByUrl ;
32
- } ,
33
- get findInfoForPublishedById ( ) {
34
- return mockFindInfoWithTextById ;
35
- } ,
30
+ findByUrl : mockBlogFindByUrl ,
31
+ findInfoForPublishedById : mockFindInfoWithTextById ,
36
32
} ) ) ;
Original file line number Diff line number Diff line change @@ -45,16 +45,8 @@ export const mockFindBlogAllDataById = jest.fn(async (id: Types.ObjectId): Promi
45
45
} ) ;
46
46
47
47
jest . mock ( '../../../../../src/database/repository/BlogRepo' , ( ) => ( {
48
- get findUrlIfExists ( ) {
49
- return mockBlogFindUrlIfExists ;
50
- } ,
51
- get create ( ) {
52
- return mockBlogCreate ;
53
- } ,
54
- get update ( ) {
55
- return mockBlogUpdate ;
56
- } ,
57
- get findBlogAllDataById ( ) {
58
- return mockFindBlogAllDataById ;
59
- } ,
48
+ findUrlIfExists : mockBlogFindUrlIfExists ,
49
+ create : mockBlogCreate ,
50
+ update : mockBlogUpdate ,
51
+ findBlogAllDataById : mockFindBlogAllDataById ,
60
52
} ) ) ;
Original file line number Diff line number Diff line change @@ -39,15 +39,11 @@ export const mockUserFindByEmail = jest.fn(async (email: string): Promise<User |
39
39
} ) ;
40
40
41
41
jest . mock ( '../../../../src/database/repository/KeystoreRepo' , ( ) => ( {
42
- get create ( ) {
43
- return mockKeystoreCreate ;
44
- } ,
42
+ create : mockKeystoreCreate ,
45
43
} ) ) ;
46
44
47
45
jest . mock ( '../../../../src/database/repository/UserRepo' , ( ) => ( {
48
- get findByEmail ( ) {
49
- return mockUserFindByEmail ;
50
- } ,
46
+ findByEmail : mockUserFindByEmail ,
51
47
} ) ) ;
52
48
53
49
jest . unmock ( '../../../../src/auth/authUtils' ) ; // remove any override made anywhere
Original file line number Diff line number Diff line change @@ -32,10 +32,6 @@ export const mockUserCreate = jest.fn(
32
32
) ;
33
33
34
34
jest . mock ( '../../../../src/database/repository/UserRepo' , ( ) => ( {
35
- get findByEmail ( ) {
36
- return mockUserFindByEmail ;
37
- } , // utilising already defined mock
38
- get create ( ) {
39
- return mockUserCreate ;
40
- } ,
35
+ findByEmail : mockUserFindByEmail , // utilising already defined mock
36
+ create : mockUserCreate ,
41
37
} ) ) ;
You can’t perform that action at this time.
0 commit comments