import { Test, TestingModule } from '@nestjs/testing'; import { StreamsService } from '../../../api/src/modules/streams/streams.service'; describe('StreamsService', () => { let service: StreamsService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [ StreamsService, { provide: 'StreamRepository', useValue: { create: jest.fn(), save: jest.fn(), findOne: jest.fn(), find: jest.fn(), update: jest.fn(), increment: jest.fn() } }, ], }).compile(); service = module.get<StreamsService>(StreamsService); }); it('should create a stream', async () => { const repo = module.get('StreamRepository'); jest.spyOn(repo, 'create').mockReturnValue({ id: '1' }); jest.spyOn(repo, 'save').mockResolvedValue({ id: '1' }); const result = await service.create('seller-1', { title: 'Test Stream' }); expect(result.id).toBe('1'); }); });