-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmutually_exclusive_currency.spec.js
101 lines (78 loc) · 4.53 KB
/
mutually_exclusive_currency.spec.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import CurrencyPage from "../../../../generated_pages/mutually_exclusive/mutually-exclusive-currency.page";
import SummaryPage from "../../../../generated_pages/mutually_exclusive/mutually-exclusive-currency-section-summary.page";
import { click } from "../../../../helpers";
describe("Component: Mutually Exclusive Currency With Single Checkbox Override", () => {
beforeEach(async () => {
await browser.openQuestionnaire("test_mutually_exclusive.json");
await browser.pause(1000);
await browser.url(CurrencyPage.url());
});
describe("Given the user has entered a value for the non-exclusive currency answer", () => {
it("When then user clicks the mutually exclusive checkbox answer, Then only the mutually exclusive checkbox should be answered.", async () => {
// Given
await $(CurrencyPage.currency()).setValue("123");
await expect(await $(CurrencyPage.currency()).getValue()).toBe("123");
// When
await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).click();
// Then
await expect(await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).isSelected()).toBe(true);
await expect(await $(CurrencyPage.currency()).getValue()).toBe("");
await click(CurrencyPage.submit());
await expect(await $(SummaryPage.currencyExclusiveAnswer()).getText()).toBe("I prefer not to say");
await expect(await $(SummaryPage.currencyExclusiveAnswer()).getText()).not.toBe("123");
});
});
describe("Given the user has clicked the mutually exclusive checkbox answer", () => {
it("When the user enters a value for the non-exclusive currency answer and removes focus, Then only the non-exclusive currency answer should be answered.", async () => {
// Given
await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).click();
await expect(await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).isSelected()).toBe(true);
// When
await $(CurrencyPage.currency()).setValue("123");
// Then
await $(CurrencyPage.currency()).getValue();
await expect(await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).isSelected()).toBe(false);
await click(CurrencyPage.submit());
await expect(await $(SummaryPage.currencyAnswer()).getText()).toBe("£123");
await expect(await $(SummaryPage.currencyAnswer()).getText()).not.toBe("I prefer not to say");
});
});
describe("Given the user has not clicked the mutually exclusive checkbox answer", () => {
it("When the user enters a value for the non-exclusive currency answer, Then only the non-exclusive currency answer should be answered.", async () => {
// Given
await expect(await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).isSelected()).toBe(false);
// When
await $(CurrencyPage.currency()).setValue("123");
// Then
await expect(await $(CurrencyPage.currency()).getValue()).toBe("123");
await expect(await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).isSelected()).toBe(false);
await click(CurrencyPage.submit());
await expect(await $(SummaryPage.currencyAnswer()).getText()).toBe("£123");
await expect(await $(SummaryPage.currencyAnswer()).getText()).not.toBe("I prefer not to say");
});
});
describe("Given the user has not answered the non-exclusive currency answer", () => {
it("When the user clicks the mutually exclusive checkbox answer, Then only the exclusive checkbox should be answered.", async () => {
// Given
await expect(await $(CurrencyPage.currency()).getValue()).toBe("");
// When
await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).click();
await expect(await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).isSelected()).toBe(true);
// Then
await click(CurrencyPage.submit());
await expect(await $(SummaryPage.currencyExclusiveAnswer()).getText()).toBe("I prefer not to say");
await expect(await $(SummaryPage.currencyExclusiveAnswer()).getText()).not.toBe("123");
});
});
describe("Given the user has not answered the question and the question is optional", () => {
it("When the user clicks the Continue button, Then it should display `No answer provided`", async () => {
// Given
await expect(await $(CurrencyPage.currency()).getValue()).toBe("");
await expect(await $(CurrencyPage.currencyExclusiveIPreferNotToSay()).isSelected()).toBe(false);
// When
await click(CurrencyPage.submit());
// Then
await expect(await $(SummaryPage.currencyAnswer()).getText()).toBe("No answer provided");
});
});
});