gecko-dev/toolkit/components/normandy/test/browser/browser_CleanupManager.js
Victor Porof 4a06c925ac Bug 1561435 - Format toolkit/components/, a=automatic-formatting
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D36052

--HG--
extra : source : b5be5b4f4b47c256e28a29f665dc754f6407ee7f
2019-07-05 11:14:05 +02:00

27 lines
835 B
JavaScript

"use strict";
ChromeUtils.import(
"resource://normandy/lib/CleanupManager.jsm",
this
); /* global CleanupManagerClass */
add_task(async function testCleanupManager() {
const spy1 = sinon.spy();
const spy2 = sinon.spy();
const spy3 = sinon.spy();
const manager = new CleanupManager.constructor();
manager.addCleanupHandler(spy1);
manager.addCleanupHandler(spy2);
manager.addCleanupHandler(spy3);
manager.removeCleanupHandler(spy2); // Test removal
await manager.cleanup();
ok(spy1.called, "cleanup called the spy1 handler");
ok(!spy2.called, "cleanup did not call the spy2 handler");
ok(spy3.called, "cleanup called the spy3 handler");
await manager.cleanup();
ok(spy1.calledOnce, "cleanup only called the spy1 handler once");
ok(spy3.calledOnce, "cleanup only called the spy3 handler once");
});