ed-safari/test/Safari.test.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-05-16 20:15:37 -07:00
import {expect, jest, it} from '@jest/globals';
import {Journal} from '../src/models/Journal';
2023-05-15 13:39:30 -07:00
import {Safari} from '../src/models/Safari';
2023-05-16 20:15:37 -07:00
describe('Safari', () => {
describe('start()', () => {
it('should return itself', () => {
const safari = Safari.start(false, true);
expect(safari).toBeDefined();
});
it('should create a new journal', () => {
const safari = Safari.start(false, true);
expect(safari.journal).toBeInstanceOf(Journal);
});
});
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();
expect(journalShutdown).toHaveBeenCalled();
});
it('should shutdown when #watcher is undefined', async () => {
const safari = Safari.start(false, true);
await expect(safari.shutdown()).resolves.not.toThrow();
});
2023-05-15 13:39:30 -07:00
});
});