@@ -3,14 +3,15 @@ import {
3
3
FastifyAdapter ,
4
4
NestFastifyApplication ,
5
5
} from '@nestjs/platform-fastify' ;
6
+ import { HttpSuccessResponse } from '@share/interfaces' ;
6
7
import { Test , TestingModule } from '@nestjs/testing' ;
8
+ import { des } from './common' ;
7
9
import { initialize } from '@util/helper' ;
8
- import { wrapDataObj } from './common' ;
9
10
10
- describe ( 'AppController (e2e) ' , ( ) => {
11
+ describe ( 'AppModule ' , ( ) => {
11
12
let app : NestFastifyApplication ;
12
13
13
- const { BASE_PATH , npm_package_version } = process . env ;
14
+ const { npm_package_version } = process . env ;
14
15
15
16
beforeAll ( async ( ) => {
16
17
const moduleFixture : TestingModule = await Test . createTestingModule ( {
@@ -27,24 +28,26 @@ describe('AppController (e2e)', () => {
27
28
await app . getHttpAdapter ( ) . getInstance ( ) . ready ( ) ;
28
29
} ) ;
29
30
30
- const versionPath = `${ BASE_PATH } /version` ;
31
- it ( `${ versionPath } (GET)` , async ( ) => {
32
- const result : VersionRes = { version : npm_package_version } ;
31
+ des ( { url : '/version' } , async ( config ) => {
32
+ it ( 'should return version number with 200 status code' , async ( ) => {
33
+ const expectedResult : VersionRes = { version : npm_package_version } ;
34
+ const response = await app . inject ( config ) ;
35
+ const actualResult = response . json < HttpSuccessResponse < VersionRes > > ( ) ;
33
36
34
- const response = await app . inject ( {
35
- url : versionPath ,
37
+ expect ( response . statusCode ) . toEqual ( 200 ) ;
38
+ expect ( actualResult . data ) . toEqual ( expectedResult ) ;
36
39
} ) ;
37
- expect ( response . statusCode ) . toEqual ( 200 ) ;
38
- expect ( response . json ( ) ) . toEqual ( wrapDataObj ( result ) ) ;
39
40
} ) ;
40
41
41
- const healthPath = `${ BASE_PATH } /healthz` ;
42
- it ( `${ healthPath } (GET)` , async ( ) => {
43
- const response = await app . inject ( {
44
- url : healthPath ,
42
+ des ( { url : '/healthz' } , async ( config ) => {
43
+ it ( 'should return health status with 200 status code' , async ( ) => {
44
+ const expectedResult = 'OK' ;
45
+ const response = await app . inject ( config ) ;
46
+ const actualResult = response . json < HttpSuccessResponse < string > > ( ) ;
47
+
48
+ expect ( response . statusCode ) . toEqual ( 200 ) ;
49
+ expect ( actualResult . data ) . toEqual ( expectedResult ) ;
45
50
} ) ;
46
- expect ( response . statusCode ) . toEqual ( 200 ) ;
47
- expect ( response . json ( ) ) . toEqual ( wrapDataObj ( 'OK' ) ) ;
48
51
} ) ;
49
52
50
53
afterAll ( async ( ) => {
0 commit comments