Make Safari tests pass again.
This commit is contained in:
parent
7dec2bd445
commit
8e6fa855ce
2 changed files with 16 additions and 23 deletions
|
@ -73,4 +73,10 @@ export class Safari extends EventEmitter {
|
|||
|
||||
return dir;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------ shutdown ---- */
|
||||
|
||||
shutdown(): void {
|
||||
this.CMDR?.shutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +1,26 @@
|
|||
import { expect, jest, it } from '@jest/globals';
|
||||
|
||||
import {Journal} from '../src/models/Journal';
|
||||
import { CMDR } from '../src/models/CMDR';
|
||||
import { Safari } from '../src/models/Safari';
|
||||
|
||||
describe('Safari', () => {
|
||||
describe('start()', () => {
|
||||
it('should return itself', () => {
|
||||
const safari = Safari.start(false, true);
|
||||
const safari = Safari.start(false);
|
||||
expect(safari).toBeDefined();
|
||||
});
|
||||
|
||||
it('should create a new journal', () => {
|
||||
const safari = Safari.start(false, true);
|
||||
expect(safari.journal).toBeInstanceOf(Journal);
|
||||
it('should create a new CMDR', () => {
|
||||
const safari = Safari.start(false);
|
||||
expect(safari.CMDR).toBeInstanceOf(CMDR);
|
||||
});
|
||||
});
|
||||
|
||||
describe('shutdown()', () => {
|
||||
it('should shutdown', async () => {
|
||||
const safari = Safari.start(false, true);
|
||||
safari.watchJournalDir();
|
||||
await expect(safari.shutdown()).resolves.not.toThrow();
|
||||
});
|
||||
|
||||
it('should shutdown journal', async () => {
|
||||
const safari = Safari.start(false, true);
|
||||
const journalShutdown = jest.spyOn(safari.journal, 'shutdown');
|
||||
safari.watchJournalDir();
|
||||
await safari.shutdown();
|
||||
const safari = Safari.start(false);
|
||||
const journalShutdown = jest.spyOn(safari.CMDR, 'shutdown');
|
||||
safari.shutdown();
|
||||
expect(journalShutdown).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should shutdown when #watcher is undefined', async () => {
|
||||
const safari = Safari.start(false, true);
|
||||
await expect(safari.shutdown()).resolves.not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue