Fixing tests
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 28s
Music Collection CI Workflow / test (./frontend) (push) Failing after 28s
Music Collection CI Workflow / deploy (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been skipped
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 28s
Music Collection CI Workflow / test (./frontend) (push) Failing after 28s
Music Collection CI Workflow / deploy (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Has been skipped
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Has been skipped
This commit is contained in:
parent
09047230ce
commit
daeb697086
@ -1,5 +1,5 @@
|
||||
import { Entity, Column, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Song } from '@/song/song.entity';
|
||||
import { Song } from '../song/song.entity';
|
||||
|
||||
@Entity()
|
||||
export class Album {
|
||||
|
@ -1,12 +1,28 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import { AlbumService } from './album.service';
|
||||
import { Album } from './album.entity';
|
||||
|
||||
const mockAlbum = new Album();
|
||||
|
||||
describe('AlbumService', () => {
|
||||
let service: AlbumService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [AlbumService],
|
||||
providers: [
|
||||
AlbumService,
|
||||
{
|
||||
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<AlbumService>(AlbumService);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Entity, Column, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Album } from '@/album/album.entity';
|
||||
import { Album } from '../album/album.entity';
|
||||
|
||||
@Entity()
|
||||
export class Song {
|
||||
|
@ -1,12 +1,28 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import { SongService } from './song.service';
|
||||
import { Song } from './song.entity';
|
||||
|
||||
const mockSong = new Song();
|
||||
|
||||
describe('SongService', () => {
|
||||
let service: SongService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [SongService],
|
||||
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),
|
||||
},
|
||||
},
|
||||
]
|
||||
}).compile();
|
||||
|
||||
service = module.get<SongService>(SongService);
|
||||
|
@ -29,7 +29,7 @@ export class SongService {
|
||||
return savedSong.id;
|
||||
}
|
||||
|
||||
async update(updateSongDto: UpdateSongDto): Promise<string> {
|
||||
async update(id: number, updateSongDto: UpdateSongDto): Promise<string> {
|
||||
if (id === updateSongDto.id) {
|
||||
const song = this.songRepository.findOneBy({ id: updateSongDto.id });
|
||||
if (!song)
|
||||
|
Loading…
x
Reference in New Issue
Block a user