-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(test): add tests for profile, game and user use cases
- Loading branch information
1 parent
4fcc557
commit e23b25f
Showing
6 changed files
with
181 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { TypeOrmGameService } from '../typeorm-game.service'; | ||
import { Game } from 'src/core'; | ||
import { Repository } from 'typeorm'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { MockDatabaseModule } from 'src/services/mock-database/mock-database.module'; | ||
|
||
describe('TypeOrmGameService', () => { | ||
let service: TypeOrmGameService; | ||
let repo: Repository<Game>; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
imports: [MockDatabaseModule, TypeOrmModule.forFeature([Game])], | ||
providers: [TypeOrmGameService], | ||
}).compile(); | ||
|
||
service = module.get<TypeOrmGameService>(TypeOrmGameService); | ||
repo = module.get<Repository<Game>>(Repository<Game>); | ||
}); | ||
|
||
it('should return an array of games', async () => { | ||
const games = [ | ||
Game.create({ | ||
title: 'Test Game 1', | ||
}), | ||
Game.create({ | ||
title: 'Test Game 2', | ||
}), | ||
]; | ||
|
||
jest.spyOn(repo, 'find').mockResolvedValue(games); | ||
|
||
const result = await service.findAll(); | ||
|
||
expect(result).toEqual(games); | ||
}); | ||
}); |
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,2 @@ | ||
export * from './telegraf-reply.module'; | ||
export * from './/telegraf-reply.service'; |
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