generated from xgeekshq/oss-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests to get board service (#1224)
- Loading branch information
1 parent
ae400aa
commit 32499c2
Showing
13 changed files
with
650 additions
and
152 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
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
18 changes: 18 additions & 0 deletions
18
backend/src/libs/test-utils/mocks/factories/boardUser-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,18 @@ | ||
import faker from '@faker-js/faker'; | ||
import { buildTestFactory } from './generic-factory.mock'; | ||
import BoardUser from 'src/modules/boards/entities/board.user.schema'; | ||
import { BoardRoles } from 'src/libs/enum/board.roles'; | ||
|
||
const mockBoardUserData = () => { | ||
return { | ||
_id: faker.database.mongodbObjectId(), | ||
role: faker.helpers.arrayElement([BoardRoles.MEMBER, BoardRoles.RESPONSIBLE]), | ||
user: faker.database.mongodbObjectId(), | ||
board: faker.database.mongodbObjectId(), | ||
votesCount: 0 | ||
}; | ||
}; | ||
|
||
export const BoardUserFactory = buildTestFactory<BoardUser>(() => { | ||
return mockBoardUserData(); | ||
}); |
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
21 changes: 21 additions & 0 deletions
21
backend/src/libs/test-utils/mocks/factories/dto/userDto-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,21 @@ | ||
import faker from '@faker-js/faker'; | ||
import UserDto from 'src/modules/users/dto/user.dto'; | ||
import { buildTestFactory } from '../generic-factory.mock'; | ||
|
||
const mockUserDto = () => { | ||
return { | ||
_id: faker.database.mongodbObjectId(), | ||
firstName: faker.name.firstName(), | ||
lastName: faker.name.lastName(), | ||
email: faker.internet.email(), | ||
strategy: faker.lorem.word(), | ||
isSAdmin: faker.datatype.boolean(), | ||
isAnonimous: faker.datatype.boolean(), | ||
providerAccountCreatedAt: faker.date.past(1), | ||
avatar: faker.internet.avatar() | ||
}; | ||
}; | ||
|
||
export const UserDtoFactory = buildTestFactory<UserDto>(() => { | ||
return mockUserDto(); | ||
}); |
18 changes: 18 additions & 0 deletions
18
backend/src/libs/test-utils/mocks/factories/team-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,18 @@ | ||
import faker from '@faker-js/faker'; | ||
import { buildTestFactory } from './generic-factory.mock'; | ||
import Team from 'src/modules/teams/entities/teams.schema'; | ||
|
||
const dateCreatedAt = faker.date.past(1); | ||
|
||
const mockTeamData = () => { | ||
return { | ||
_id: faker.database.mongodbObjectId(), | ||
name: faker.company.companyName(), | ||
createdAt: dateCreatedAt, | ||
upddatedAt: faker.date.between(dateCreatedAt, Date.now()) | ||
}; | ||
}; | ||
|
||
export const TeamFactory = buildTestFactory<Team>(() => { | ||
return mockTeamData(); | ||
}); |
18 changes: 18 additions & 0 deletions
18
backend/src/libs/test-utils/mocks/factories/teamUser-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,18 @@ | ||
import faker from '@faker-js/faker'; | ||
import { buildTestFactory } from './generic-factory.mock'; | ||
import { TeamRoles } from 'src/libs/enum/team.roles'; | ||
import TeamUser from 'src/modules/teams/entities/team.user.schema'; | ||
|
||
const mockTeamUserData = () => { | ||
return { | ||
_id: faker.database.mongodbObjectId(), | ||
role: faker.helpers.arrayElement([TeamRoles.MEMBER, TeamRoles.ADMIN, TeamRoles.STAKEHOLDER]), | ||
isNewJoiner: faker.datatype.boolean(), | ||
user: faker.database.mongodbObjectId(), | ||
team: faker.database.mongodbObjectId() | ||
}; | ||
}; | ||
|
||
export const TeamUserFactory = buildTestFactory<TeamUser>(() => { | ||
return mockTeamUserData(); | ||
}); |
22 changes: 22 additions & 0 deletions
22
backend/src/libs/test-utils/mocks/factories/user-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 { buildTestFactory } from './generic-factory.mock'; | ||
import User from 'src/modules/users/entities/user.schema'; | ||
|
||
const mockUserData = () => { | ||
return { | ||
_id: faker.database.mongodbObjectId(), | ||
firstName: faker.name.firstName(), | ||
lastName: faker.name.lastName(), | ||
password: faker.internet.password(), | ||
email: faker.internet.email(), | ||
joinedAt: faker.date.past(1), | ||
strategy: faker.lorem.word(), | ||
isSAdmin: faker.datatype.boolean(), | ||
isDeleted: faker.datatype.boolean(), | ||
isAnonymous: faker.datatype.boolean() | ||
}; | ||
}; | ||
|
||
export const UserFactory = buildTestFactory<User>(() => { | ||
return mockUserData(); | ||
}); |
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.