diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js')
-rw-r--r-- | browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js b/browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js new file mode 100644 index 0000000000..b697721401 --- /dev/null +++ b/browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js @@ -0,0 +1,38 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +"use strict"; + +const { AboutWelcomeChild } = ChromeUtils.import( + "resource:///actors/AboutWelcomeChild.jsm" +); +const { sinon } = ChromeUtils.import("resource://testing-common/Sinon.jsm"); + +const TEST_ATTRIBUTION_DATA = { + source: "addons.mozilla.org", + medium: "referral", + campaign: "non-fx-button", + content: "iridium%40particlecore.github.io", +}; + +add_task(async function test_handleAddonInfoNotFound() { + let AWChild = new AboutWelcomeChild(); + const stub = sinon.stub(AWChild, "getAddonInfo").resolves(null); + let result = await AWChild.formatAttributionData(TEST_ATTRIBUTION_DATA); + equal(stub.callCount, 1, "Call was made"); + equal(result.template, undefined, "No template returned"); +}); + +add_task(async function test_formatAttributionData() { + let AWChild = new AboutWelcomeChild(); + const TEST_ADDON_INFO = { + name: "Test Add-on", + url: "https://test.xpi", + iconURL: "http://test.svg", + }; + sinon.stub(AWChild, "getAddonInfo").resolves(TEST_ADDON_INFO); + let result = await AWChild.formatAttributionData(TEST_ATTRIBUTION_DATA); + equal(result.template, "return_to_amo", "RTAMO template returned"); + equal(result.extraProps, TEST_ADDON_INFO, "AddonInfo returned"); +}); |