From 6d17fc880d2d3f876078a35aee4e2b5f629e50bf Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Thu, 22 Jun 2017 09:00:16 -0400 Subject: [PATCH] Opportunistic native watcher stopping --- spec/filesystem-manager-spec.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/filesystem-manager-spec.js b/spec/filesystem-manager-spec.js index a37aee108..bece1d09e 100644 --- a/spec/filesystem-manager-spec.js +++ b/spec/filesystem-manager-spec.js @@ -83,7 +83,23 @@ describe('FileSystemManager', function () { expect(started).toBe(true) }) - it('automatically stops and removes the watcher when all onDidChange subscribers dispose') + it('automatically stops and removes the watcher when all onDidChange subscribers dispose', async function () { + const dir = await temp.mkdir('atom-fsmanager-') + const watcher = manager.getWatcher(dir) + + const sub0 = watcher.onDidChange(() => {}) + const sub1 = watcher.onDidChange(() => {}) + + await watcher.getStartPromise() + expect(watcher.native).not.toBe(null) + expect(watcher.native.isRunning()).toBe(true) + + sub0.dispose() + expect(watcher.native.isRunning()).toBe(true) + + sub1.dispose() + expect(watcher.native.isRunning()).toBe(false) + }) it('reuses an existing native watcher and resolves getStartPromise immediately if attached to a running watcher', async function () { const rootDir = await temp.mkdir('atom-fsmanager-')