feat(watchlist): settings, commands, catch-up scheduler wiring
This commit is contained in:
parent
e8cb9b93fe
commit
f9cc324ead
4 changed files with 203 additions and 0 deletions
40
tests/watchlist-controller.test.ts
Normal file
40
tests/watchlist-controller.test.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { describe, expect, test } from 'bun:test';
|
||||
import { WatchlistController } from 'packages/obsidian/src/watchlist/WatchlistController';
|
||||
|
||||
function fakePlugin(overrides: Partial<{ enabled: boolean; last: number; hours: number }> = {}) {
|
||||
return {
|
||||
settings: {
|
||||
watchlistEnabled: overrides.enabled ?? true,
|
||||
watchlistLastSync: overrides.last ?? 0,
|
||||
watchlistSyncIntervalHours: overrides.hours ?? 24,
|
||||
watchlistFolder: 'Watchlist',
|
||||
TMDBKeyId: 'kid',
|
||||
},
|
||||
saveSettings: async () => {},
|
||||
app: {},
|
||||
} as any;
|
||||
}
|
||||
|
||||
describe('maybeCatchUp', () => {
|
||||
test('overdue → syncs', async () => {
|
||||
const c = new WatchlistController(fakePlugin({ last: 0 }));
|
||||
let called = false;
|
||||
(c as any).syncNow = async () => { called = true; return {} as any; };
|
||||
await c.maybeCatchUp();
|
||||
expect(called).toBe(true);
|
||||
});
|
||||
test('recent sync → no call', async () => {
|
||||
const c = new WatchlistController(fakePlugin({ last: Date.now() }));
|
||||
let called = false;
|
||||
(c as any).syncNow = async () => { called = true; return {} as any; };
|
||||
await c.maybeCatchUp();
|
||||
expect(called).toBe(false);
|
||||
});
|
||||
test('disabled → no call', async () => {
|
||||
const c = new WatchlistController(fakePlugin({ enabled: false, last: 0 }));
|
||||
let called = false;
|
||||
(c as any).syncNow = async () => { called = true; return {} as any; };
|
||||
await c.maybeCatchUp();
|
||||
expect(called).toBe(false);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue