Bug 1895534 - Add unit test for pocketFeedParameters Nimbus variable. r=amy,home-newtab-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D209708
This commit is contained in:
Mathijs 2024-05-09 16:02:01 +00:00
parent 618f1268a4
commit 2f36d75c2a

View file

@ -3467,6 +3467,22 @@ describe("DiscoveryStreamFeed", () => {
"https://bffApi/desktop/v1/recommendations?locale=$locale&region=$region&count=30"
);
});
it("should update the new feed url with pocketFeedParameters", async () => {
globals.set("NimbusFeatures", {
pocketNewtab: {
getVariable: sandbox.stub(),
},
});
global.NimbusFeatures.pocketNewtab.getVariable
.withArgs("pocketFeedParameters")
.returns("&enableRankingByRegion=1");
await feed.loadLayout(feed.store.dispatch);
const { layout } = feed.store.getState().DiscoveryStream;
assert.equal(
layout[0].components[2].feed.url,
"https://bffApi/desktop/v1/recommendations?locale=$locale&region=$region&count=30&enableRankingByRegion=1"
);
});
it("should fetch proper data from getComponentFeed", async () => {
const fakeCache = {};
sandbox.stub(feed.cache, "get").returns(Promise.resolve(fakeCache));