From bcf621c78167c832de175d96cae1e9fab122ef85 Mon Sep 17 00:00:00 2001 From: amy churchwell Date: Thu, 21 Oct 2021 15:42:01 +0000 Subject: [PATCH] Bug 1735724 - Add unit test for 200 OK with empty tiles array response from Contile. r=nanj Differential Revision: https://phabricator.services.mozilla.com/D129088 --- .../newtab/test/unit/lib/TopSitesFeed.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/browser/components/newtab/test/unit/lib/TopSitesFeed.test.js b/browser/components/newtab/test/unit/lib/TopSitesFeed.test.js index 1b63eb0e0834..686ae8592223 100644 --- a/browser/components/newtab/test/unit/lib/TopSitesFeed.test.js +++ b/browser/components/newtab/test/unit/lib/TopSitesFeed.test.js @@ -2136,6 +2136,22 @@ describe("Top Sites Feed", () => { assert.ok(!feed._contile.sites.length); }); + it("should handle empty payload properly from Contile", async () => { + fetchStub.resolves({ + ok: true, + status: 200, + json: () => + Promise.resolve({ + tiles: [], + }), + }); + + const fetched = await feed._contile._fetchSites(); + + assert.ok(fetched); + assert.ok(!feed._contile.sites.length); + }); + it("should handle no content properly from Contile", async () => { fetchStub.resolves({ ok: true, status: 204 });