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