generated from xgeekshq/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b3ff06
commit 4118fff
Showing
26 changed files
with
1,034 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
backend/src/libs/test-utils/mocks/factories/dto/boardDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import faker from '@faker-js/faker'; | ||
import { BoardPhases } from 'src/libs/enum/board.phases'; | ||
import BoardDto from 'src/modules/boards/dto/board.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
import { ColumnDtoFactory } from './columnDto-factory.mock'; | ||
|
||
const mockBoardDto = () => { | ||
return { | ||
_id: faker.database.mongodbObjectId(), | ||
title: faker.lorem.words(), | ||
columns: ColumnDtoFactory.createMany(3), | ||
isPublic: faker.datatype.boolean(), | ||
maxVotes: faker.datatype.number({ min: 0, max: 6 }), | ||
maxUsers: 0, | ||
maxTeams: '1', | ||
hideCards: faker.datatype.boolean(), | ||
hideVotes: faker.datatype.boolean(), | ||
dividedBoards: [], | ||
team: '1', | ||
socketId: faker.datatype.uuid(), | ||
users: [], | ||
recurrent: faker.datatype.boolean(), | ||
isSubBoard: faker.datatype.boolean(), | ||
boardNumber: 0, | ||
slackEnable: faker.datatype.boolean(), | ||
addCards: faker.datatype.boolean(), | ||
responsibles: ['1'], | ||
createdBy: faker.datatype.uuid(), | ||
addcards: faker.datatype.boolean(), | ||
postAnonymously: faker.datatype.boolean(), | ||
createdAt: faker.datatype.datetime().toISOString(), | ||
phase: faker.helpers.arrayElement([ | ||
BoardPhases.ADDCARDS, | ||
BoardPhases.SUBMITTED, | ||
BoardPhases.VOTINGPHASE | ||
]) | ||
}; | ||
}; | ||
|
||
export const BoardDtoFactory = buildTestFactory<BoardDto>(() => { | ||
return mockBoardDto(); | ||
}); |
20 changes: 20 additions & 0 deletions
20
backend/src/libs/test-utils/mocks/factories/dto/boardUserDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import faker from '@faker-js/faker'; | ||
import { BoardRoles } from 'src/libs/enum/board.roles'; | ||
import BoardUserDto from 'src/modules/boards/dto/board.user.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
import { UserFactory } from '../user-factory'; | ||
|
||
const mockBoardUserDto = () => { | ||
return { | ||
id: faker.datatype.uuid(), | ||
role: faker.helpers.arrayElement([BoardRoles.MEMBER, BoardRoles.RESPONSIBLE]), | ||
user: UserFactory.create(), | ||
board: faker.datatype.uuid(), | ||
votesCount: Math.random() * 10, | ||
isNewJoiner: faker.datatype.boolean() | ||
}; | ||
}; | ||
|
||
export const BoardUserDtoFactory = buildTestFactory<BoardUserDto>(() => { | ||
return mockBoardUserDto(); | ||
}); |
21 changes: 21 additions & 0 deletions
21
backend/src/libs/test-utils/mocks/factories/dto/cardDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import faker from '@faker-js/faker'; | ||
import CardDto from 'src/modules/cards/dto/card.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
import { CardItemDtoFactory } from './cardItemDto-factory.mock'; | ||
import { CommentDtoFactory } from './commentsDto-factory.mock'; | ||
|
||
const mockCardDto = () => { | ||
return { | ||
items: [CardItemDtoFactory.create()], | ||
id: faker.database.mongodbObjectId(), | ||
text: faker.lorem.words(), | ||
createdBy: faker.datatype.uuid(), | ||
comments: [CommentDtoFactory.create()], | ||
votes: [], | ||
anonymous: faker.datatype.boolean() | ||
}; | ||
}; | ||
|
||
export const CardDtoFactory = buildTestFactory<CardDto>(() => { | ||
return mockCardDto(); | ||
}); |
19 changes: 19 additions & 0 deletions
19
backend/src/libs/test-utils/mocks/factories/dto/cardItemDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import faker from '@faker-js/faker'; | ||
import CardItemDto from 'src/modules/cards/dto/card.item.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
import { CommentDtoFactory } from './commentsDto-factory.mock'; | ||
|
||
const mockCardItemDto = () => { | ||
return { | ||
id: faker.database.mongodbObjectId(), | ||
text: faker.lorem.words(), | ||
createdBy: faker.datatype.uuid(), | ||
comments: [CommentDtoFactory.create()], | ||
votes: [], | ||
anonymous: faker.datatype.boolean() | ||
}; | ||
}; | ||
|
||
export const CardItemDtoFactory = buildTestFactory<CardItemDto>(() => { | ||
return mockCardItemDto(); | ||
}); |
26 changes: 26 additions & 0 deletions
26
backend/src/libs/test-utils/mocks/factories/dto/columnDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import faker from '@faker-js/faker'; | ||
import ColumnDto from 'src/modules/columns/dto/column.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
import { CardDtoFactory } from './cardDto-factory.mock'; | ||
|
||
const mockColumnDto = () => { | ||
return { | ||
_id: faker.database.mongodbObjectId(), | ||
title: faker.lorem.words(), | ||
color: faker.helpers.arrayElement([ | ||
'#CDFAE0', | ||
'#DEB7FF', | ||
'#9BFDFA', | ||
'#FE9EBF', | ||
'#9DCAFF', | ||
'#FEB9A9' | ||
]), | ||
cards: [CardDtoFactory.create()], | ||
cardText: faker.lorem.words(), | ||
isDefaultText: faker.datatype.boolean() | ||
}; | ||
}; | ||
|
||
export const ColumnDtoFactory = buildTestFactory<ColumnDto>(() => { | ||
return mockColumnDto(); | ||
}); |
15 changes: 15 additions & 0 deletions
15
backend/src/libs/test-utils/mocks/factories/dto/commentsDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import faker from '@faker-js/faker'; | ||
import CommentDto from 'src/modules/comments/dto/comment.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
|
||
const mockCommentDto = () => { | ||
return { | ||
text: faker.lorem.words(), | ||
createdBy: faker.datatype.uuid(), | ||
anonymous: faker.datatype.boolean() | ||
}; | ||
}; | ||
|
||
export const CommentDtoFactory = buildTestFactory<CommentDto>(() => { | ||
return mockCommentDto(); | ||
}); |
22 changes: 22 additions & 0 deletions
22
backend/src/libs/test-utils/mocks/factories/dto/teamDto-factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import faker from '@faker-js/faker'; | ||
import { ForTeamDtoEnum, TeamDto } from 'src/modules/communication/dto/team.dto'; | ||
import { BoardRoles } from 'src/modules/communication/dto/types'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
import { UserCommunicationDtoFactory } from './userCommunicationDto-factory.mock'; | ||
|
||
const mockTeamCommunicationDto = () => { | ||
return { | ||
name: faker.company.companyName(), | ||
normalName: faker.company.companyName(), | ||
boardId: faker.datatype.uuid(), | ||
channelId: faker.datatype.uuid(), | ||
type: faker.helpers.arrayElement([ForTeamDtoEnum.SUBTEAM, ForTeamDtoEnum.TEAM]), | ||
for: faker.helpers.arrayElement([BoardRoles.MEMBER, BoardRoles.RESPONSIBLE]), | ||
participants: UserCommunicationDtoFactory.createMany(2), | ||
teamNumber: Math.random() * 10 | ||
}; | ||
}; | ||
|
||
export const TeamCommunicationDtoFactory = buildTestFactory<TeamDto>(() => { | ||
return mockTeamCommunicationDto(); | ||
}); |
15 changes: 15 additions & 0 deletions
15
backend/src/libs/test-utils/mocks/factories/dto/updateBoardDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { UpdateBoardDto } from 'src/modules/boards/dto/update-board.dto'; | ||
import { BoardUserFactory } from '../boardUser-factory.mock'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
import { BoardDtoFactory } from './boardDto-factory.mock'; | ||
|
||
const mockUpdateBoardDto = () => { | ||
return { | ||
responsible: BoardUserFactory.create(), | ||
...BoardDtoFactory.create() | ||
}; | ||
}; | ||
|
||
export const UpdateBoardDtoFactory = buildTestFactory<UpdateBoardDto>(() => { | ||
return mockUpdateBoardDto(); | ||
}); |
19 changes: 19 additions & 0 deletions
19
backend/src/libs/test-utils/mocks/factories/dto/userCommunicationDto-factory.mock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import faker from '@faker-js/faker'; | ||
import { UserDto } from 'src/modules/communication/dto/user.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
|
||
const mockUserCommunicationDto = () => { | ||
return { | ||
id: faker.datatype.uuid(), | ||
firstName: faker.name.firstName(), | ||
lastName: faker.name.lastName(), | ||
email: faker.internet.email(), | ||
responsible: faker.datatype.boolean(), | ||
boardId: faker.datatype.uuid(), | ||
slackId: faker.datatype.uuid() | ||
}; | ||
}; | ||
|
||
export const UserCommunicationDtoFactory = buildTestFactory<UserDto>(() => { | ||
return mockUserCommunicationDto(); | ||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
backend/src/modules/boards/interfaces/applications/update.board.application.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.