add unit tests
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user