gecko-dev/browser/components/newtab/test/unit/activity-stream.test.jsx
Ed Lee 52414287aa Bug 1508407 - Add Return-to-AMO firstrun, Pocket-personalization attachment and bug fixes to Activity Stream r=ursula
Differential Revision: https://phabricator.services.mozilla.com/D12343

--HG--
rename : browser/components/newtab/content-src/components/StartupOverlay/StartupOverlay.jsx => browser/components/newtab/content-src/asrouter/templates/StartupOverlay/StartupOverlay.jsx
rename : browser/components/newtab/content-src/components/StartupOverlay/_StartupOverlay.scss => browser/components/newtab/content-src/asrouter/templates/StartupOverlay/_StartupOverlay.scss
extra : moz-landing-system : lando
2018-11-19 22:05:29 +00:00

40 lines
1.3 KiB
JavaScript

import {combineReducers, createStore} from "redux";
import {actionTypes as at} from "common/Actions.jsm";
import {enableASRouterContent} from "content-src/lib/asroutercontent.js";
import {reducers} from "common/Reducers.jsm";
describe("asrouter", () => {
let sandbox;
let store;
let asrouterContent;
beforeEach(() => {
sandbox = sinon.createSandbox();
store = createStore(combineReducers(reducers));
sandbox.spy(store, "subscribe");
});
afterEach(() => {
sandbox.restore();
});
it("should initialize asrouter once if ASRouter.initialized is true", () => {
({asrouterContent} = enableASRouterContent(store, {
init: sandbox.stub(),
initialized: false,
}));
store.dispatch({type: at.AS_ROUTER_INITIALIZED, data: {}});
asrouterContent.initialized = true;
// Dispatch another irrelevant event to make sure we don't initialize twice.
store.dispatch({type: at.PREF_CHANGED, data: {name: "foo", value: "bar"}});
assert.calledWith(asrouterContent.init, store);
});
it("should do nothing if ASRouter is not initialized", () => {
const addStub = sandbox.stub(global.document.body.classList, "add");
({asrouterContent} = enableASRouterContent(store, {
init: sandbox.stub(),
initialized: false,
}));
store.dispatch({type: at.INIT});
assert.notCalled(addStub);
});
});