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(
3939) ;
4040
4141jest . mock ( '../../../src/database/repository/UserRepo' , ( ) => ( {
42- get findById ( ) {
43- return mockUserFindById ;
44- } ,
42+ findById : mockUserFindById ,
4543} ) ) ;
4644
4745jest . mock ( '../../../src/database/repository/KeystoreRepo' , ( ) => ( {
48- get findforKey ( ) {
49- return mockKeystoreFindForKey ;
50- } ,
46+ findforKey : mockKeystoreFindForKey ,
5147} ) ) ;
5248
5349JWT . 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
6868} ) ;
6969
7070export const mockJwtValidate = jest . fn ( async ( token : string ) : Promise < JwtPayload > => {
71- let subject = null ;
71+ let subject : null | string = null ;
7272 switch ( token ) {
7373 case ACCESS_TOKEN :
7474 subject = USER_ID . toHexString ( ) ;
@@ -93,15 +93,11 @@ export const mockJwtValidate = jest.fn(async (token: string): Promise<JwtPayload
9393} ) ;
9494
9595jest . mock ( '../../../src/database/repository/UserRepo' , ( ) => ( {
96- get findById ( ) {
97- return mockUserFindById ;
98- } ,
96+ findById : mockUserFindById ,
9997} ) ) ;
10098
10199jest . mock ( '../../../src/database/repository/RoleRepo' , ( ) => ( {
102- get findByCode ( ) {
103- return mockRoleRepoFindByCode ;
104- } ,
100+ findByCode : mockRoleRepoFindByCode ,
105101} ) ) ;
106102
107103JWT . validate = mockJwtValidate ;
Original file line number Diff line number Diff line change @@ -27,10 +27,6 @@ export const mockFindInfoWithTextById = jest.fn(
2727) ;
2828
2929jest . 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 ,
3632} ) ) ;
Original file line number Diff line number Diff line change @@ -45,16 +45,8 @@ export const mockFindBlogAllDataById = jest.fn(async (id: Types.ObjectId): Promi
4545} ) ;
4646
4747jest . 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 ,
6052} ) ) ;
Original file line number Diff line number Diff line change @@ -39,15 +39,11 @@ export const mockUserFindByEmail = jest.fn(async (email: string): Promise<User |
3939} ) ;
4040
4141jest . mock ( '../../../../src/database/repository/KeystoreRepo' , ( ) => ( {
42- get create ( ) {
43- return mockKeystoreCreate ;
44- } ,
42+ create : mockKeystoreCreate ,
4543} ) ) ;
4644
4745jest . mock ( '../../../../src/database/repository/UserRepo' , ( ) => ( {
48- get findByEmail ( ) {
49- return mockUserFindByEmail ;
50- } ,
46+ findByEmail : mockUserFindByEmail ,
5147} ) ) ;
5248
5349jest . 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(
3232) ;
3333
3434jest . 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 ,
4137} ) ) ;
You can’t perform that action at this time.
0 commit comments