Skip to content

Commit 9f615b2

Browse files
committed
Add unit tests for AppVaccinateFormComponent#dose_sequence
1 parent 4687fb3 commit 9f615b2

1 file changed

Lines changed: 103 additions & 67 deletions

File tree

Lines changed: 103 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# frozen_string_literal: true
22

33
describe AppVaccinateFormComponent do
4-
subject { render_inline(component) }
5-
64
let(:programme) { Programme.sample }
75
let(:programmes) { [programme] }
86

@@ -27,92 +25,130 @@
2725

2826
let(:component) { described_class.new(vaccinate_form) }
2927

30-
it { should have_css(".nhsuk-card") }
28+
describe "#render" do
29+
subject { render_inline(component) }
3130

32-
context "with a flu programme" do
33-
let(:programme) { Programme.flu }
31+
it { should have_css(".nhsuk-card") }
3432

35-
it { should have_content("Has Hari confirmed their identity?") }
36-
it { should have_field("No, it was confirmed by somebody else") }
33+
context "with a flu programme" do
34+
let(:programme) { Programme.flu }
3735

38-
it { should have_heading("Is Hari ready for their flu injection?") }
36+
it { should have_content("Has Hari confirmed their identity?") }
37+
it { should have_field("No, it was confirmed by somebody else") }
3938

40-
it { should have_field("Yes") }
41-
it { should have_field("No") }
39+
it { should have_heading("Is Hari ready for their flu injection?") }
4240

43-
it { should have_field("Left arm (upper position)") }
44-
it { should have_field("Right arm (upper position)") }
45-
it { should_not have_field("Nose") }
46-
it { should have_field("Other") }
47-
end
41+
it { should have_field("Yes") }
42+
it { should have_field("No") }
4843

49-
context "with a flu programme and consent to nasal spray" do
50-
let(:programme) { Programme.flu }
51-
let(:academic_year) { AcademicYear.current }
52-
53-
let(:patient) do
54-
create(
55-
:patient,
56-
:consent_given_nasal_only_triage_not_needed,
57-
:in_attendance,
58-
session:,
59-
given_name: "Hari"
60-
)
44+
it { should have_field("Left arm (upper position)") }
45+
it { should have_field("Right arm (upper position)") }
46+
it { should_not have_field("Nose") }
47+
it { should have_field("Other") }
6148
end
6249

63-
it { should have_content("Has Hari confirmed their identity?") }
64-
it { should have_field("No, it was confirmed by somebody else") }
50+
context "with a flu programme and consent to nasal spray" do
51+
let(:programme) { Programme.flu }
52+
let(:academic_year) { AcademicYear.current }
6553

66-
it { should have_heading("Is Hari ready for their flu nasal spray?") }
54+
let(:patient) do
55+
create(
56+
:patient,
57+
:consent_given_nasal_only_triage_not_needed,
58+
:in_attendance,
59+
session:,
60+
given_name: "Hari"
61+
)
62+
end
6763

68-
it { should have_field("Yes") }
69-
it { should have_field("No") }
64+
it { should have_content("Has Hari confirmed their identity?") }
65+
it { should have_field("No, it was confirmed by somebody else") }
7066

71-
it { should_not have_field("Left arm (upper position)") }
72-
it { should_not have_field("Right arm (upper position)") }
73-
it { should_not have_field("Nose") }
74-
it { should_not have_field("Other") }
75-
end
67+
it { should have_heading("Is Hari ready for their flu nasal spray?") }
68+
69+
it { should have_field("Yes") }
70+
it { should have_field("No") }
71+
72+
it { should_not have_field("Left arm (upper position)") }
73+
it { should_not have_field("Right arm (upper position)") }
74+
it { should_not have_field("Nose") }
75+
it { should_not have_field("Other") }
76+
end
7677

77-
context "with a flu programme, consent to nasal spray, but triaged for injection" do
78-
let(:programme) { Programme.flu }
79-
let(:academic_year) { AcademicYear.current }
80-
81-
let(:patient) do
82-
create(
83-
:patient,
84-
:consent_given_injection_and_nasal_triage_safe_to_vaccinate_injection,
85-
:in_attendance,
86-
session:,
87-
given_name: "Hari"
88-
)
78+
context "with a flu programme, consent to nasal spray, but triaged for injection" do
79+
let(:programme) { Programme.flu }
80+
let(:academic_year) { AcademicYear.current }
81+
82+
let(:patient) do
83+
create(
84+
:patient,
85+
:consent_given_injection_and_nasal_triage_safe_to_vaccinate_injection,
86+
:in_attendance,
87+
session:,
88+
given_name: "Hari"
89+
)
90+
end
91+
92+
it { should have_heading("Is Hari ready for their flu injection?") }
93+
94+
it { should have_field("Yes") }
95+
it { should have_field("No") }
96+
97+
it { should have_field("Left arm (upper position)") }
98+
it { should have_field("Right arm (upper position)") }
99+
it { should_not have_field("Nose") }
100+
it { should have_field("Other") }
89101
end
90102

91-
it { should have_heading("Is Hari ready for their flu injection?") }
103+
context "with an HPV programme" do
104+
let(:programme) { Programme.hpv }
105+
106+
it { should have_content("Has Hari confirmed their identity?") }
107+
it { should have_field("No, it was confirmed by somebody else") }
108+
109+
it { should have_heading("Is Hari ready for their HPV vaccination?") }
92110

93-
it { should have_field("Yes") }
94-
it { should have_field("No") }
111+
it { should have_field("Yes") }
112+
it { should have_field("No") }
95113

96-
it { should have_field("Left arm (upper position)") }
97-
it { should have_field("Right arm (upper position)") }
98-
it { should_not have_field("Nose") }
99-
it { should have_field("Other") }
114+
it { should have_field("Left arm (upper position)") }
115+
it { should have_field("Right arm (upper position)") }
116+
it { should_not have_field("Nose") }
117+
it { should have_field("Other") }
118+
end
100119
end
101120

102-
context "with an HPV programme" do
103-
let(:programme) { Programme.hpv }
121+
describe "#dose_sequence" do
122+
subject { component.send(:dose_sequence) }
123+
124+
context "with HPV programme" do
125+
let(:programme) { Programme.hpv }
104126

105-
it { should have_content("Has Hari confirmed their identity?") }
106-
it { should have_field("No, it was confirmed by somebody else") }
127+
it { should eq(1) }
128+
end
129+
130+
context "with Td/IPV programme" do
131+
let(:programme) { Programme.td_ipv }
132+
133+
it { should be_nil }
134+
end
135+
136+
context "with MenACWY programme" do
137+
let(:programme) { Programme.menacwy }
107138

108-
it { should have_heading("Is Hari ready for their HPV vaccination?") }
139+
it { should be_nil }
140+
end
141+
142+
context "with flu programme" do
143+
let(:programme) { Programme.flu }
109144

110-
it { should have_field("Yes") }
111-
it { should have_field("No") }
145+
it { should eq(1) }
146+
end
112147

113-
it { should have_field("Left arm (upper position)") }
114-
it { should have_field("Right arm (upper position)") }
115-
it { should_not have_field("Nose") }
116-
it { should have_field("Other") }
148+
context "with MMR programme" do
149+
let(:programme) { Programme.mmr }
150+
151+
it { should be_nil }
152+
end
117153
end
118154
end

0 commit comments

Comments
 (0)