gecko-dev/toolkit/components/normandy/test/browser/browser_ActionsManager.js
Michael Cooper 490749ff91 Bug 1513646 - Remove Normandy remote-action infrastructure r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D28227

--HG--
extra : moz-landing-system : lando
2019-04-23 13:23:07 +00:00

35 lines
1.2 KiB
JavaScript

"use strict";
ChromeUtils.import("resource://normandy/lib/ActionsManager.jsm", this);
ChromeUtils.import("resource://normandy/lib/NormandyApi.jsm", this);
ChromeUtils.import("resource://normandy/lib/Uptake.jsm", this);
// Test life cycle methods for actions
decorate_task(
async function(reportActionStub, Stub) {
let manager = new ActionsManager();
const recipe = {id: 1, action: "test-local-action-used"};
let actionUsed = {
runRecipe: sinon.stub(),
finalize: sinon.stub(),
};
let actionUnused = {
runRecipe: sinon.stub(),
finalize: sinon.stub(),
};
manager.localActions = {
"test-local-action-used": actionUsed,
"test-local-action-unused": actionUnused,
};
await manager.runRecipe(recipe);
await manager.finalize();
Assert.deepEqual(actionUsed.runRecipe.args, [[recipe]], "used action should be called with the recipe");
ok(actionUsed.finalize.calledOnce, "finalize should be called on used action");
Assert.deepEqual(actionUnused.runRecipe.args, [], "unused action should not be called with the recipe");
ok(actionUnused.finalize.calledOnce, "finalize should be called on the unused action");
},
);