Bug 1524593 - (Follow-up) Test fixes nsISearchService changes

This commit is contained in:
Andrei Oprea 2019-02-04 16:38:45 +01:00 коммит произвёл k88hudson
Родитель bfa2ac84ed
Коммит 5e171cbf09
3 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -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 = {};

Просмотреть файл

@ -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);

Просмотреть файл

@ -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",