summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js')
-rw-r--r--browser/components/newtab/test/xpcshell/test_AboutWelcomeAttribution.js38
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");
+});