All checks were successful
Music Collection CI Workflow / test (./backend) (push) Successful in 29s
Music Collection CI Workflow / test (./frontend) (push) Successful in 34s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/music-collection-backend, ./backend) (push) Successful in 50s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m48s
Music Collection CI Workflow / deploy (push) Successful in 2s
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { getRepositoryToken } from '@nestjs/typeorm';
|
|
import { SongService } from './song.service';
|
|
import { Song } from './song.entity';
|
|
import { Album } from '../album/album.entity';
|
|
|
|
const mockSong = new Song();
|
|
const mockAlbum = new Album();
|
|
|
|
describe('SongService', () => {
|
|
let service: SongService;
|
|
|
|
beforeEach(async () => {
|
|
const module: TestingModule = await Test.createTestingModule({
|
|
providers: [
|
|
SongService,
|
|
{
|
|
provide: getRepositoryToken(Song),
|
|
useValue: {
|
|
findAll: jest.fn().mockResolvedValue([mockSong]),
|
|
findOneById: jest.fn().mockResolvedValue(mockSong),
|
|
create: jest.fn().mockResolvedValue(1),
|
|
update: jest.fn().mockResolvedValue("Song updated successfully"),
|
|
remove: jest.fn().mockResolvedValue(null),
|
|
},
|
|
},
|
|
{
|
|
provide: getRepositoryToken(Album),
|
|
useValue: {
|
|
findAll: jest.fn().mockResolvedValue([mockAlbum]),
|
|
findOneById: jest.fn().mockResolvedValue(mockAlbum),
|
|
create: jest.fn().mockResolvedValue(1),
|
|
update: jest.fn().mockResolvedValue("Album updated successfully"),
|
|
remove: jest.fn().mockResolvedValue(null),
|
|
},
|
|
},
|
|
]
|
|
}).compile();
|
|
|
|
service = module.get<SongService>(SongService);
|
|
});
|
|
|
|
it('should be defined', () => {
|
|
expect(service).toBeDefined();
|
|
});
|
|
});
|