mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 14:20:14 +02:00
Differential Revision: https://phabricator.services.mozilla.com/D28227 --HG-- extra : moz-landing-system : lando
35 lines
1.2 KiB
JavaScript
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");
|
|
},
|
|
);
|
|
|