File tree Expand file tree Collapse file tree 6 files changed +16
-13
lines changed Expand file tree Collapse file tree 6 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export const mockUserFindById = jest.fn(async (id: Types.ObjectId) => {
44
44
} ) ;
45
45
46
46
export const mockRoleRepoFindByCode = jest . fn (
47
- async ( code : string ) : Promise < Role > => {
47
+ async ( code : string ) : Promise < Role | null > => {
48
48
switch ( code ) {
49
49
case RoleCode . WRITER :
50
50
return {
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export const BLOG_ID = new Types.ObjectId();
7
7
export const BLOG_URL = 'abc' ;
8
8
9
9
export const mockBlogFindByUrl = jest . fn (
10
- async ( blogUrl : string ) : Promise < Blog > => {
10
+ async ( blogUrl : string ) : Promise < Blog | null > => {
11
11
if ( blogUrl === BLOG_URL )
12
12
return {
13
13
_id : BLOG_ID ,
@@ -18,7 +18,7 @@ export const mockBlogFindByUrl = jest.fn(
18
18
) ;
19
19
20
20
export const mockFindInfoWithTextById = jest . fn (
21
- async ( id : Types . ObjectId ) : Promise < Blog > => {
21
+ async ( id : Types . ObjectId ) : Promise < Blog | null > => {
22
22
if ( BLOG_ID . equals ( id ) )
23
23
return {
24
24
_id : BLOG_ID ,
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export const BLOG_ID_2 = new Types.ObjectId();
9
9
export const BLOG_URL = 'abc' ;
10
10
11
11
export const mockBlogFindUrlIfExists = jest . fn (
12
- async ( blogUrl : string ) : Promise < Blog > => {
12
+ async ( blogUrl : string ) : Promise < Blog | null > => {
13
13
if ( blogUrl === BLOG_URL )
14
14
return {
15
15
_id : BLOG_ID ,
@@ -29,7 +29,7 @@ export const mockBlogCreate = jest.fn(
29
29
export const mockBlogUpdate = jest . fn ( async ( blog : Blog ) : Promise < Blog > => blog ) ;
30
30
31
31
export const mockFindBlogAllDataById = jest . fn (
32
- async ( id : Types . ObjectId ) : Promise < Blog > => {
32
+ async ( id : Types . ObjectId ) : Promise < Blog | null > => {
33
33
if ( BLOG_ID . equals ( id ) )
34
34
return {
35
35
_id : BLOG_ID ,
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ describe('Login basic route', () => {
22
22
const password = '123456' ;
23
23
24
24
let user : User ;
25
- let apikey : ApiKey ;
25
+ let apikey : ApiKey | null ;
26
26
27
27
beforeAll ( async ( ) => {
28
28
await UserModel . remove ( { } ) ; // delete all data from user table
@@ -168,5 +168,5 @@ describe('Login basic route', () => {
168
168
} ) ;
169
169
} ) ;
170
170
171
- export const addHeaders = ( request : any , apikey : ApiKey ) =>
172
- request . set ( 'Content-Type' , 'application/json' ) . set ( 'x-api-key' , apikey . key ) ;
171
+ export const addHeaders = ( request : any , apikey : ApiKey | null ) =>
172
+ request . set ( 'Content-Type' , 'application/json' ) . set ( 'x-api-key' , apikey ? .key ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export const mockKeystoreCreate = jest.fn(
25
25
) ;
26
26
27
27
export const mockUserFindByEmail = jest . fn (
28
- async ( email : string ) : Promise < User > => {
28
+ async ( email : string ) : Promise < User | null > => {
29
29
if ( email === USER_EMAIL )
30
30
return {
31
31
_id : USER_ID ,
Original file line number Diff line number Diff line change @@ -112,10 +112,13 @@ describe('Login basic route', () => {
112
112
113
113
it ( 'Should send success response for correct credentials' , async ( ) => {
114
114
const response = await addHeaders (
115
- request . post ( endpoint ) . send ( {
116
- email : USER_EMAIL ,
117
- password : USER_PASSWORD ,
118
- } ) ,
115
+ request
116
+ . post ( endpoint )
117
+ . send ( {
118
+ email : USER_EMAIL ,
119
+ password : USER_PASSWORD ,
120
+ } )
121
+ . timeout ( 5000 ) ,
119
122
) ;
120
123
expect ( response . status ) . toBe ( 200 ) ;
121
124
expect ( response . body . message ) . toMatch ( / S u c c e s s / i) ;
You can’t perform that action at this time.
0 commit comments