it("should do nothing if the section doesn't exist", () => {
   SectionsManager.removeSection(FAKE_ID);
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.UPDATE_SECTION, spy);
   SectionsManager.updateSection(FAKE_ID, {rows: FAKE_ROWS}, true);
   assert.notCalled(spy);
 });
 it("should do nothing if the section doesn't exist", () => {
   SectionsManager.removeSection(FAKE_ID);
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.UPDATE_SECTION_CARD, spy);
   SectionsManager.updateSectionCard(FAKE_ID, FAKE_URL, FAKE_CARD_OPTIONS, true);
   assert.notCalled(spy);
 });
 it("should emit a DISABLE_SECTION event", () => {
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.DISABLE_SECTION, spy);
   SectionsManager.disableSection(FAKE_ID);
   assert.calledOnce(spy);
   assert.calledWith(spy, SectionsManager.DISABLE_SECTION, FAKE_ID);
 });
 it("should do nothing if the section doesn't exist", () => {
   SectionsManager.removeSection(FAKE_ID);
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.UPDATE_SECTION, spy);
   SectionsManager.removeSectionCard(FAKE_ID, "bar.com");
   assert.notCalled(spy);
 });
 it("should add the id to sections and emit an ADD_SECTION event", () => {
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.ADD_SECTION, spy);
   SectionsManager.addSection(FAKE_ID, FAKE_OPTIONS);
   assert.ok(SectionsManager.sections.has(FAKE_ID));
   assert.calledOnce(spy);
   assert.calledWith(spy, SectionsManager.ADD_SECTION, FAKE_ID, FAKE_OPTIONS);
 });
 it("should emit an UNINIT event and set SectionsManager.initialized to false", () => {
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.UNINIT, spy);
   feed.init();
   feed.uninit();
   assert.calledOnce(spy);
   assert.notOk(SectionsManager.initialized);
 });
 it("should emit an UPDATE_SECTION_CARD event with correct arguments", () => {
   SectionsManager.addSection(FAKE_ID, Object.assign({}, FAKE_OPTIONS, {rows: FAKE_ROWS}));
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.UPDATE_SECTION_CARD, spy);
   SectionsManager.updateSectionCard(FAKE_ID, FAKE_URL, FAKE_CARD_OPTIONS, true);
   assert.calledOnce(spy);
   assert.calledWith(spy, SectionsManager.UPDATE_SECTION_CARD, FAKE_ID,
     FAKE_URL, FAKE_CARD_OPTIONS, true);
 });
 it("should emit an UPDATE_SECTION event with correct arguments", () => {
   SectionsManager.addSection(FAKE_ID, FAKE_OPTIONS);
   const spy = sinon.spy();
   const dedupeConfigurations = [{id: "topstories", dedupeFrom: ["highlights"]}];
   SectionsManager.on(SectionsManager.UPDATE_SECTION, spy);
   SectionsManager.updateSection(FAKE_ID, {rows: FAKE_ROWS}, true);
   assert.calledOnce(spy);
   assert.calledWith(spy, SectionsManager.UPDATE_SECTION, FAKE_ID, {rows: FAKE_ROWS, dedupeConfigurations}, true);
 });
 it("should remove the id from sections and emit an REMOVE_SECTION event", () => {
   // Ensure we start with the id in the set
   assert.ok(SectionsManager.sections.has(FAKE_ID));
   const spy = sinon.spy();
   SectionsManager.on(SectionsManager.REMOVE_SECTION, spy);
   SectionsManager.removeSection(FAKE_ID);
   assert.notOk(SectionsManager.sections.has(FAKE_ID));
   assert.calledOnce(spy);
   assert.calledWith(spy, SectionsManager.REMOVE_SECTION, FAKE_ID);
 });
    it("should dispatch an SECTION_UPDATE action in which cards corresponding to the given url are removed", () => {
      const rows = [{url: "foo.com"}, {url: "bar.com"}];

      SectionsManager.addSection(FAKE_ID, Object.assign({}, FAKE_OPTIONS, {rows}));
      const spy = sinon.spy();
      SectionsManager.on(SectionsManager.UPDATE_SECTION, spy);
      SectionsManager.removeSectionCard(FAKE_ID, "foo.com");

      assert.calledOnce(spy);
      assert.equal(spy.firstCall.args[1], FAKE_ID);
      assert.deepEqual(spy.firstCall.args[2].rows, [{url: "bar.com"}]);
    });
 it("should emit a ACTION_DISPATCHED event and forward any action in ACTIONS_TO_PROXY if there are any sections", () => {
   const spy = sinon.spy();
   const allowedActions = SectionsManager.ACTIONS_TO_PROXY;
   const disallowedActions = ["PREF_CHANGED", "OPEN_PRIVATE_WINDOW"];
   feed.init();
   SectionsManager.on(SectionsManager.ACTION_DISPATCHED, spy);
   // Make sure we start with no sections - no event should be emitted
   SectionsManager.sections.clear();
   feed.onAction({type: allowedActions[0]});
   assert.notCalled(spy);
   // Then add a section and check correct behaviour
   SectionsManager.addSection(FAKE_ID, FAKE_OPTIONS);
   for (const action of allowedActions.concat(disallowedActions)) {
     feed.onAction({type: action});
   }
   for (const action of allowedActions) {
     assert.calledWith(spy, "ACTION_DISPATCHED", action);
   }
   for (const action of disallowedActions) {
     assert.neverCalledWith(spy, "ACTION_DISPATCHED", action);
   }
 });