|
- import {FastifyInstance} from 'fastify';
- import Uuid from '@tonality/library-uuid';
- import {models} from '@tonality/library-common';
- import {PrismaClient as RealPrismaClient} from '@prisma/client';
- import {MockPrismaRepository} from '../../../../src/utils/mocks';
- import {container} from 'tsyringe';
- import {build} from '../../../helper';
-
- jest.mock('@prisma/client')
- const PrismaClient = RealPrismaClient as jest.Mock
-
- describe('ringtone: /api/search/ringtones', () => {
- let app: FastifyInstance
-
- beforeEach(() => {
- PrismaClient.mockImplementationOnce(() => ({
- user: new MockPrismaRepository<models.User>([
- {
- id: Uuid.parse('00000000-0000-0000-0000-000000000000'),
- username: 'TheoryOfNekomata',
- password: 'dummy password',
- },
- ], 'id'),
- ringtone: new MockPrismaRepository<models.Ringtone>([
- {
- id: Uuid.parse('00000000-0000-0000-0000-000000000000'),
- name: 'Ringtone 1',
- data: '4c4',
- tempo: 120,
- createdAt: new Date('2021-05-01'),
- updatedAt: new Date('2021-05-01'),
- deletedAt: null,
- composerUserId: Uuid.parse('00000000-0000-0000-0000-000000000000'),
- },
- {
- id: Uuid.parse('8df2751c-4c05-4831-9408-92af3b4a63e8'),
- name: 'Unique Ringtone 2',
- data: '4c4 8c4',
- tempo: 120,
- createdAt: new Date('2021-05-01'),
- updatedAt: new Date('2021-05-01'),
- deletedAt: null,
- composerUserId: Uuid.parse('00000000-0000-0000-0000-000000000000'),
- },
- {
- id: Uuid.parse('c8423931-6a08-41f6-8320-a5ce5367179f'),
- name: 'Deleted Ringtone 1',
- data: '4c4',
- tempo: 120,
- createdAt: new Date('2021-05-01'),
- updatedAt: new Date('2021-05-01'),
- deletedAt: new Date('2021-05-05'),
- composerUserId: Uuid.parse('00000000-0000-0000-0000-000000000000'),
- },
- ], 'id')
- }))
- })
-
- beforeEach(async () => {
- app = await build()
- })
-
- afterEach(async () => {
- container.clearInstances()
- await app.close()
- })
-
- it.todo('should foo')
- })
|