MobileDownloads.test.jsx (1976B)
1 import React from "react"; 2 import { shallow, mount } from "enzyme"; 3 import { GlobalOverrider } from "asrouter/tests/unit/utils"; 4 import { MobileDownloads } from "content-src/components/MobileDownloads"; 5 6 describe("Multistage AboutWelcome MobileDownloads module", () => { 7 let globals; 8 let sandbox; 9 10 beforeEach(async () => { 11 globals = new GlobalOverrider(); 12 globals.set({ 13 AWFinish: () => Promise.resolve(), 14 AWSendToDeviceEmailsSupported: () => Promise.resolve(), 15 }); 16 sandbox = sinon.createSandbox(); 17 }); 18 19 afterEach(() => { 20 sandbox.restore(); 21 globals.restore(); 22 }); 23 24 describe("Mobile Downloads component", () => { 25 const MOBILE_DOWNLOADS_PROPS = { 26 data: { 27 QR_code: { 28 image_url: 29 "chrome://browser/components/privatebrowsing/content/assets/focus-qr-code.svg", 30 alt_text: { 31 string_id: "spotlight-focus-promo-qr-code", 32 }, 33 }, 34 email: { 35 link_text: "Email yourself a link", 36 }, 37 marketplace_buttons: ["ios", "android"], 38 }, 39 handleAction: () => { 40 window.AWFinish(); 41 }, 42 }; 43 44 it("should render MobileDownloads", () => { 45 const wrapper = shallow(<MobileDownloads {...MOBILE_DOWNLOADS_PROPS} />); 46 47 assert.ok(wrapper.exists()); 48 }); 49 50 it("should handle action on markeplace badge click", () => { 51 const wrapper = mount(<MobileDownloads {...MOBILE_DOWNLOADS_PROPS} />); 52 53 const stub = sandbox.stub(global, "AWFinish"); 54 wrapper.find(".ios button").simulate("click"); 55 wrapper.find(".android button").simulate("click"); 56 57 assert.calledTwice(stub); 58 }); 59 60 it("should handle action on email button click", () => { 61 const wrapper = shallow(<MobileDownloads {...MOBILE_DOWNLOADS_PROPS} />); 62 63 const stub = sandbox.stub(global, "AWFinish"); 64 wrapper.find("button.email-link").simulate("click"); 65 66 assert.calledOnce(stub); 67 }); 68 }); 69 });