-
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.
- Loading branch information
Showing
7 changed files
with
25 additions
and
25 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
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
6 changes: 3 additions & 3 deletions
6
...rc/infra/db/repository/pair-repository.ts → ...ra/db/query-service/pair-query-service.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import { GetPairsUsecase } from './get-pairs-usecase'; | ||
import { PairRepository } from '../../infra/db/repository/pair-repository'; | ||
import { PairQueryService } from '../../infra/db/query-service/pair-query-service'; | ||
import { PrismaClient } from '@prisma/client'; | ||
|
||
jest.mock('@prisma/client'); | ||
jest.mock('../../infra/db/repository/pair-repository'); | ||
jest.mock('../../infra/db/query-service/pair-query-service'); | ||
|
||
describe('GetPairsUsecase', () => { | ||
let mockRepository: jest.MockedObjectDeep<PairRepository>; | ||
let mockQueryService: jest.MockedObjectDeep<PairQueryService>; | ||
|
||
beforeAll(() => { | ||
const prisma = new PrismaClient(); | ||
mockRepository = jest.mocked(new PairRepository(prisma)); | ||
mockQueryService = jest.mocked(new PairQueryService(prisma)); | ||
}); | ||
|
||
describe('do', () => { | ||
it('正常系 PairRepository.findAllを1回コールすること', async () => { | ||
it('正常系 PairQueryService.findAllを1回コールすること', async () => { | ||
// Act | ||
const usecase = new GetPairsUsecase(mockRepository); | ||
const usecase = new GetPairsUsecase(mockQueryService); | ||
await usecase.do(); | ||
|
||
// Assert | ||
expect(mockRepository.findAll).toHaveBeenCalledTimes(1); | ||
expect(mockQueryService.findAll).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
}); |
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,12 +1,12 @@ | ||
import { | ||
IPairRepository, | ||
IPairQueryService, | ||
PairDto, | ||
} from '../../domain/repository-interface/pair-repository'; | ||
} from './query-service-interface/pair-query-service'; | ||
|
||
export class GetPairsUsecase { | ||
constructor(private pairRepository: IPairRepository) {} | ||
constructor(private pairQueryService: IPairQueryService) {} | ||
|
||
async do(): Promise<PairDto[]> { | ||
return await this.pairRepository.findAll(); | ||
return await this.pairQueryService.findAll(); | ||
} | ||
} |
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