Adding some tests, still trying to resolve edit/create
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 28s
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 49s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Failing after 1m27s
Music Collection CI Workflow / deploy (push) Has been skipped
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 28s
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 49s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Failing after 1m27s
Music Collection CI Workflow / deploy (push) Has been skipped
This commit is contained in:
parent
5b6a6004da
commit
ed7c3ff3d6
@ -3,11 +3,14 @@ import { getRepositoryToken } from '@nestjs/typeorm';
|
|||||||
import { AlbumController } from './album.controller';
|
import { AlbumController } from './album.controller';
|
||||||
import { AlbumService } from './album.service';
|
import { AlbumService } from './album.service';
|
||||||
import { Album } from './album.entity';
|
import { Album } from './album.entity';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
|
||||||
const mockAlbum = new Album();
|
const mockAlbum = new Album();
|
||||||
|
|
||||||
describe('AlbumController', () => {
|
describe('AlbumController', () => {
|
||||||
let controller: AlbumController;
|
let controller: AlbumController;
|
||||||
|
let service: AlbumService;
|
||||||
|
let repository: Repository<Album>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
@ -17,8 +20,8 @@ describe('AlbumController', () => {
|
|||||||
{
|
{
|
||||||
provide: getRepositoryToken(Album),
|
provide: getRepositoryToken(Album),
|
||||||
useValue: {
|
useValue: {
|
||||||
findAll: jest.fn().mockResolvedValue([mockAlbum]),
|
find: jest.fn().mockResolvedValue([mockAlbum]),
|
||||||
findOneById: jest.fn().mockResolvedValue(mockAlbum),
|
findOne: jest.fn().mockResolvedValue(mockAlbum),
|
||||||
create: jest.fn().mockResolvedValue(1),
|
create: jest.fn().mockResolvedValue(1),
|
||||||
update: jest.fn().mockResolvedValue("Album updated successfully"),
|
update: jest.fn().mockResolvedValue("Album updated successfully"),
|
||||||
remove: jest.fn().mockResolvedValue(null),
|
remove: jest.fn().mockResolvedValue(null),
|
||||||
@ -28,9 +31,23 @@ describe('AlbumController', () => {
|
|||||||
}).compile();
|
}).compile();
|
||||||
|
|
||||||
controller = module.get<AlbumController>(AlbumController);
|
controller = module.get<AlbumController>(AlbumController);
|
||||||
|
service = module.get<AlbumService>(AlbumService);
|
||||||
|
repository = module.get<Repository<Album>>(getRepositoryToken(Album));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be defined', () => {
|
it('should be defined', () => {
|
||||||
expect(controller).toBeDefined();
|
expect(controller).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('findAll', () => {
|
||||||
|
it('should return an array of Albums', async () => {
|
||||||
|
expect(await service.findAll()).toStrictEqual([mockAlbum]);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('findOneById', () => {
|
||||||
|
it('should return an Album', async () => {
|
||||||
|
expect(await service.findOneById(1)).toStrictEqual(mockAlbum);
|
||||||
|
})
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
@ -46,7 +46,7 @@ export default function Page() {
|
|||||||
|
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isBlank(formData.get('id') as string)) {
|
if (formData.get('id') == "") {
|
||||||
const data = await createSong(formData);
|
const data = await createSong(formData);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,7 +40,7 @@ export default function Page() {
|
|||||||
|
|
||||||
const formData = new FormData(event.currentTarget);
|
const formData = new FormData(event.currentTarget);
|
||||||
try {
|
try {
|
||||||
if (StringUtils.isBlank(formData.get('id') as string)) {
|
if (formData.get('id') == "") {
|
||||||
const data = await createAlbum(formData);
|
const data = await createAlbum(formData);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user