This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
6c9366b
commit a710e35
Showing
4 changed files
with
60 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
import { Team } from '../teams.schema'; | ||
|
||
export class Results { | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,9 +51,7 @@ describe('TeamService', () => { | |
envFilePath: `.dev.env`, | ||
}), | ||
rootMongooseTestModule(), | ||
MongooseModule.forFeature([ | ||
{ name: Team.name, schema: TeamsSchema }, | ||
]), | ||
MongooseModule.forFeature([{ name: Team.name, schema: TeamsSchema }]), | ||
/* Serving the static files. */ | ||
ServeStaticModule.forRoot({ | ||
rootPath: path.resolve(__dirname, 'static'), | ||
|
@@ -168,7 +166,7 @@ describe('TeamService', () => { | |
}); | ||
|
||
it('should create 100 users and 100 teams', async () => { | ||
let users = await createMultipleUsers(100); | ||
const users = await createMultipleUsers(100); | ||
|
||
for (let i = 0; i < users.length; i++) { | ||
await teamsService.createTeam(CreateTeamDtoStub(users[i]._id)); | ||
|
@@ -196,9 +194,7 @@ describe('TeamService', () => { | |
it('should create user, give him role, create team, then create another user invite him to team and double check everything was updated', async () => { | ||
const user1 = await createUser(); | ||
|
||
const team = await teamsService.createTeam( | ||
CreateTeamDtoStub(user1._id), | ||
); | ||
const team = await teamsService.createTeam(CreateTeamDtoStub(user1._id)); | ||
|
||
await userService.updateAvatar(UpdateUserAvatarDtoStub(user1.email, 1)); | ||
|
||
|
@@ -224,9 +220,7 @@ describe('TeamService', () => { | |
it('should create user, give him role, create team, then create another user invite him to team and double check invite has image field', async () => { | ||
const user1 = await createUser(); | ||
|
||
const team = await teamsService.createTeam( | ||
CreateTeamDtoStub(user1._id), | ||
); | ||
const team = await teamsService.createTeam(CreateTeamDtoStub(user1._id)); | ||
|
||
const user2 = await userService.createUser( | ||
RegisterUserDtoStub('[email protected]'), | ||
|
@@ -289,9 +283,7 @@ describe('TeamService', () => { | |
|
||
for (let i = 0; i < users.length; i++) { | ||
const notification = | ||
await notificationService.getTeamNotificationsForUser( | ||
users[i]._id, | ||
); | ||
await notificationService.getTeamNotificationsForUser(users[i]._id); | ||
|
||
/* Checking if the notification is defined. */ | ||
expect(notification[0]).toBeDefined(); | ||
|
@@ -350,9 +342,7 @@ describe('TeamService', () => { | |
const updatedTeam = await teamsService.updateTeam(incoming_update_data); | ||
|
||
expect(updatedTeam.name).toEqual(incoming_update_data.name); | ||
expect(updatedTeam.description).toEqual( | ||
incoming_update_data.description, | ||
); | ||
expect(updatedTeam.description).toEqual(incoming_update_data.description); | ||
expect(updatedTeam.country).toEqual(incoming_update_data.country); | ||
expect(updatedTeam.tag).toEqual(incoming_update_data.tag); | ||
expect(updatedTeam.type).toEqual(incoming_update_data.type); | ||
|
@@ -382,9 +372,7 @@ describe('TeamService', () => { | |
await teamsService.createTeam(CreateTeamDtoStub(user._id)); | ||
|
||
// @ts-ignore | ||
await expect(teamsService.updateTeam({})).rejects.toThrow( | ||
HttpException, | ||
); | ||
await expect(teamsService.updateTeam({})).rejects.toThrow(HttpException); | ||
}); | ||
|
||
it('should create user, then create team and then call updateTeam with only required teamid', async () => { | ||
|
@@ -409,7 +397,7 @@ describe('TeamService', () => { | |
}); | ||
|
||
it('should create 5 users and 5 teams', async () => { | ||
let users = await createMultipleUsers(5); | ||
const users = await createMultipleUsers(5); | ||
|
||
await teamsService.createTeam(CreateTeamDtoStub(users[0]._id, 'TEG1')); | ||
await teamsService.createTeam(CreateTeamDtoStub(users[1]._id, 'TEG2')); | ||
|
@@ -427,14 +415,12 @@ describe('TeamService', () => { | |
}); | ||
|
||
it('should create 10 users and 10 teams, make 1 team have 3 players and filter by team with 3 players', async () => { | ||
let users = await createMultipleUsers(10); | ||
const users = await createMultipleUsers(10); | ||
|
||
let team: Team; | ||
|
||
for (let i = 0; i < 7; i++) { | ||
team = await teamsService.createTeam( | ||
CreateTeamDtoStub(users[i]._id), | ||
); | ||
team = await teamsService.createTeam(CreateTeamDtoStub(users[i]._id)); | ||
} | ||
|
||
await teamsService.joinTeam({ | ||
|
@@ -448,20 +434,20 @@ describe('TeamService', () => { | |
}); | ||
|
||
expect( | ||
(await teamsService.getFilteredTeamsByPage(1, 9, { members: [3] })) | ||
.total, | ||
(await teamsService.getFilteredTeamsByPage(1, 9, { members: [3] })).total, | ||
).toBe(1); | ||
}); | ||
|
||
it('should create 10 users and 10 teams, make 1 team have 3 players and 1 team 4 players and filter by team with 3 players', async () => { | ||
let users = await createMultipleUsers(10); | ||
|
||
let team1: Team; | ||
let team2: Team; | ||
const users = await createMultipleUsers(10); | ||
|
||
team1 = await teamsService.createTeam(CreateTeamDtoStub(users[0]._id)); | ||
const team1 = await teamsService.createTeam( | ||
CreateTeamDtoStub(users[0]._id), | ||
); | ||
|
||
team2 = await teamsService.createTeam(CreateTeamDtoStub(users[1]._id)); | ||
const team2 = await teamsService.createTeam( | ||
CreateTeamDtoStub(users[1]._id), | ||
); | ||
|
||
// add 3 members to team1 | ||
for (let i = 2; i < 4; i++) { | ||
|