1
1
import { Test , TestingModule } from '@nestjs/testing' ;
2
- import { INestApplication } from '@nestjs/common' ;
2
+ import { INestApplication , ValidationPipe } from '@nestjs/common' ;
3
3
import { AppModule } from '../src/app.module' ;
4
4
import { UsersService } from '../src/users/users.service' ;
5
5
import { requestWithAuth , haveUserLogged } from './preconditions' ;
6
6
import { ProjectsService } from '../src/projects/projects.service' ;
7
7
import uuidAPIKey from 'uuid-apikey' ;
8
8
import { UserLoginResponseDto } from 'src/users/dto/user-login-response.dto' ;
9
+ import { ProjectDto } from 'src/projects/dto/project.dto' ;
9
10
10
- const project = {
11
+ const project : ProjectDto = {
11
12
id : uuidAPIKey . create ( ) . uuid ,
12
13
name : 'Test project' ,
14
+ buildsCounter : 0 ,
15
+ mainBranchName : 'master' ,
16
+ createdAt : new Date ( ) ,
17
+ updatedAt : new Date ( ) ,
18
+ autoApproveFeature : true ,
19
+ imageComparison : 'pixelmatch' ,
20
+ maxBuildAllowed : 0 ,
21
+ maxBranchLifetime : 0 ,
22
+ imageComparisonConfig : '{}'
13
23
} ;
14
24
15
25
const projectServiceMock = {
@@ -33,6 +43,7 @@ describe('Projects (e2e)', () => {
33
43
. compile ( ) ;
34
44
35
45
app = moduleFixture . createNestApplication ( ) ;
46
+ app . useGlobalPipes ( new ValidationPipe ( ) ) ;
36
47
usersService = moduleFixture . get < UsersService > ( UsersService ) ;
37
48
38
49
await app . init ( ) ;
@@ -81,7 +92,11 @@ describe('Projects (e2e)', () => {
81
92
it ( 'can delete' , async ( ) => {
82
93
const res = await requestWithAuth ( app , 'delete' , `/projects/${ project . id } ` , loggedUser . token ) . send ( ) . expect ( 200 ) ;
83
94
84
- expect ( res . body ) . toStrictEqual ( projectServiceMock . remove ( ) ) ;
95
+ expect ( res . body ) . toStrictEqual ( {
96
+ ...projectServiceMock . remove ( ) ,
97
+ createdAt : expect . any ( String ) ,
98
+ updatedAt : expect . any ( String ) ,
99
+ } ) ;
85
100
} ) ;
86
101
87
102
it ( 'not valid UUID' , async ( ) => {
@@ -97,7 +112,11 @@ describe('Projects (e2e)', () => {
97
112
it ( 'can edit' , async ( ) => {
98
113
const res = await requestWithAuth ( app , 'put' , `/projects` , loggedUser . token ) . send ( project ) . expect ( 200 ) ;
99
114
100
- expect ( res . body ) . toStrictEqual ( projectServiceMock . update ( ) ) ;
115
+ expect ( res . body ) . toStrictEqual ( {
116
+ ...projectServiceMock . update ( ) ,
117
+ createdAt : expect . any ( String ) ,
118
+ updatedAt : expect . any ( String ) ,
119
+ } ) ;
101
120
} ) ;
102
121
103
122
it ( 'not valid token' , async ( ) => {
0 commit comments