FaviconFeed.test.js (980B)
1 "use strict"; 2 import { FaviconFeed } from "lib/FaviconFeed.sys.mjs"; 3 import { actionTypes as at } from "common/Actions.mjs"; 4 import { GlobalOverrider } from "test/unit/utils"; 5 6 describe("FaviconFeed", () => { 7 let feed; 8 let sandbox; 9 let globals; 10 11 beforeEach(() => { 12 globals = new GlobalOverrider(); 13 sandbox = globals.sandbox; 14 15 feed = new FaviconFeed(); 16 sandbox.stub(feed.faviconProvider, "fetchIcon").resolves(); 17 feed.store = { 18 dispatch: sinon.spy(), 19 }; 20 }); 21 afterEach(() => { 22 globals.restore(); 23 }); 24 25 it("should create a FaviconFeed", () => { 26 assert.instanceOf(feed, FaviconFeed); 27 }); 28 29 describe("#onAction", () => { 30 it("should fetchIcon on RICH_ICON_MISSING", async () => { 31 const url = "https://mozilla.org"; 32 feed.onAction({ type: at.RICH_ICON_MISSING, data: { url } }); 33 assert.calledOnce(feed.faviconProvider.fetchIcon); 34 assert.calledWith(feed.faviconProvider.fetchIcon, url); 35 }); 36 }); 37 });