diff --git a/test/unit/lib/SnippetsFeed.test.js b/test/unit/lib/SnippetsFeed.test.js index 1568dbfa3..d3d0a370f 100644 --- a/test/unit/lib/SnippetsFeed.test.js +++ b/test/unit/lib/SnippetsFeed.test.js @@ -167,6 +167,15 @@ describe("SnippetsFeed", () => { assert.equal(action.type, at.SNIPPETS_DATA); assert.deepEqual(action.data, {selectedSearchEngine: searchData}); }); + it("should catch errors when calling getVisibleEngines", async () => { + const feed = new SnippetsFeed(); + sandbox.stub(global.Services.search, "getVisibleEngines").rejects(); + + const result = await feed.getSelectedSearchEngine(); + + assert.lengthOf(result.engines, 0); + assert.equal(result.searchEngineIdentifier, ""); + }); it("should call showFirefoxAccounts", () => { const feed = new SnippetsFeed(); const browser = {}; diff --git a/test/unit/lib/TopSitesFeed.test.js b/test/unit/lib/TopSitesFeed.test.js index 14b6fa606..3a402196b 100644 --- a/test/unit/lib/TopSitesFeed.test.js +++ b/test/unit/lib/TopSitesFeed.test.js @@ -1124,7 +1124,7 @@ describe("Top Sites Feed", () => { describe("improvesearch.noDefaultSearchTile experiment", () => { const NO_DEFAULT_SEARCH_TILE_PREF = "improvesearch.noDefaultSearchTile"; beforeEach(() => { - global.Services.search.getDefault = async () => {identifier: "google", searchForm: "google.com"}; + global.Services.search.getDefault = async () => ({identifier: "google", searchForm: "google.com"}); feed.store.state.Prefs.values[NO_DEFAULT_SEARCH_TILE_PREF] = true; }); it("should filter out alexa top 5 search from the default sites", async () => { @@ -1162,7 +1162,7 @@ describe("Top Sites Feed", () => { }); it("should call refresh and set ._currentSearchHostname to the new engine hostname when the the default search engine has been set", () => { sinon.stub(feed, "refresh"); - global.Services.search.getDefault = async () => {identifier: "ddg", searchForm: "duckduckgo.com"}; + sandbox.stub(global.Services.search, "defaultEngine").value({identifier: "ddg", searchForm: "duckduckgo.com"}); feed.observe(null, "browser-search-engine-modified", "engine-current"); assert.equal(feed._currentSearchHostname, "duckduckgo"); assert.calledOnce(feed.refresh); diff --git a/test/unit/unit-entry.js b/test/unit/unit-entry.js index 5acc92faa..0efb2b617 100644 --- a/test/unit/unit-entry.js +++ b/test/unit/unit-entry.js @@ -218,8 +218,8 @@ const TEST_GLOBAL = { }), }, search: { - init(cb) { cb(); }, - getVisibleEngines: () => [{identifier: "google"}, {identifier: "bing"}], + init() { return Promise.resolve(); }, + getVisibleEngines: () => Promise.resolve([{identifier: "google"}, {identifier: "bing"}]), defaultEngine: { identifier: "google", searchForm: "https://www.google.com/search?q=&ie=utf-8&oe=utf-8&client=firefox-b",