Update
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import monitorModule from '../src/main/repository-monitor.cjs';
|
||||
|
||||
const { RepositoryMonitor } = monitorModule;
|
||||
|
||||
test('repository monitor establishes a baseline and emits only on later changes', async () => {
|
||||
let revision = 1;
|
||||
const changes = [];
|
||||
const git = {
|
||||
status: async (localPath) => ({ localPath, revision }),
|
||||
statusFingerprint: (status) => String(status.revision)
|
||||
};
|
||||
const store = { data: { preferences: { autoRefresh: true, repositoryPollSeconds: 2 } } };
|
||||
const monitor = new RepositoryMonitor({ store, git, onChange: (change) => changes.push(change) });
|
||||
monitor.setPaths(['/repo']);
|
||||
await monitor.tick();
|
||||
assert.equal(changes.length, 0);
|
||||
revision = 2;
|
||||
await monitor.tick();
|
||||
assert.equal(changes.length, 1);
|
||||
assert.equal(changes[0].reason, 'working-tree-changed');
|
||||
monitor.pause('/repo');
|
||||
revision = 3;
|
||||
await monitor.tick();
|
||||
assert.equal(changes.length, 1);
|
||||
monitor.resume('/repo');
|
||||
await monitor.tick();
|
||||
assert.equal(changes.length, 2);
|
||||
});
|
||||
Reference in New Issue
Block a user