add unit tests

This commit is contained in:
2026-03-10 00:05:08 +01:00
parent db6a230696
commit 7170e4a08e
17 changed files with 862 additions and 50 deletions

View File

@@ -1,5 +1,4 @@
import {TestBed} from '@angular/core/testing';
import {EditSongGuard} from './edit-song.guard';
describe('EditSongGuard', () => {
@@ -11,6 +10,22 @@ describe('EditSongGuard', () => {
});
it('should be created', () => {
void expect(guard).toBeTruthy();
expect(guard).toBeTruthy();
});
it('should allow navigation when there is no nested editSongComponent', () => {
const result = guard.canDeactivate({editSongComponent: null} as never, {} as never, {} as never, {} as never);
expect(result).toBeTrue();
});
it('should delegate to askForSave on the nested editSongComponent', async () => {
const nextState = {url: '/songs'} as never;
const askForSave = jasmine.createSpy('askForSave').and.resolveTo(true);
const result = await guard.canDeactivate({editSongComponent: {askForSave}} as never, {} as never, {} as never, nextState);
expect(askForSave).toHaveBeenCalledWith(nextState);
expect(result).toBeTrue();
});
});