|
3 | 3 | describe AppPatientVaccinationTableComponent do |
4 | 4 | subject { render_inline(component) } |
5 | 5 |
|
6 | | - let(:component) do |
7 | | - described_class.new(patient, show_caption:, show_programme:) |
8 | | - end |
| 6 | + let(:component) { described_class.new(patient, programme:, show_caption:) } |
9 | 7 |
|
10 | 8 | let(:patient) { create(:patient) } |
| 9 | + let(:programme) { nil } |
11 | 10 | let(:show_caption) { false } |
12 | | - let(:show_programme) { false } |
13 | 11 |
|
14 | 12 | it { should have_content("No vaccinations") } |
15 | 13 |
|
16 | 14 | context "with a vaccination record" do |
17 | | - let(:programme) { create(:programme, :hpv) } |
18 | | - |
19 | 15 | let(:location) do |
20 | 16 | create( |
21 | 17 | :school, |
|
26 | 22 | ) |
27 | 23 | end |
28 | 24 |
|
| 25 | + let(:vaccination_record_programme) { create(:programme, :hpv) } |
| 26 | + |
29 | 27 | before do |
30 | 28 | create( |
31 | 29 | :vaccination_record, |
32 | 30 | patient:, |
33 | | - session: create(:session, location:, programmes: [programme]), |
34 | | - programme:, |
| 31 | + session: |
| 32 | + create( |
| 33 | + :session, |
| 34 | + location:, |
| 35 | + programmes: [vaccination_record_programme] |
| 36 | + ), |
| 37 | + programme: vaccination_record_programme, |
35 | 38 | performed_at: Time.zone.local(2024, 1, 1) |
36 | 39 | ) |
37 | 40 | end |
|
40 | 43 | it { should have_content("Test School") } |
41 | 44 | it { should have_content("Waterloo Road, London, SE1 8TY") } |
42 | 45 | it { should have_content("Vaccinated") } |
43 | | - it { should_not have_content("HPV") } |
| 46 | + it { should have_content("HPV") } |
| 47 | + |
| 48 | + context "when showing records from a specific programme" do |
| 49 | + let(:programme) { vaccination_record_programme } |
| 50 | + |
| 51 | + it { should_not have_content("HPV") } |
| 52 | + end |
44 | 53 |
|
45 | | - context "when showing the programme" do |
46 | | - let(:show_programme) { true } |
| 54 | + context "with a vaccination record from a different programme" do |
| 55 | + let(:programme) { create(:programme, :hpv) } |
| 56 | + let(:vaccination_record_programme) { create(:programme, :flu) } |
47 | 57 |
|
48 | | - it { should have_content("HPV") } |
| 58 | + it { should_not have_link("1 January 2024") } |
| 59 | + it { should_not have_content("Test School") } |
| 60 | + it { should_not have_content("Waterloo Road, London, SE1 8TY") } |
| 61 | + it { should_not have_content("Vaccinated") } |
| 62 | + it { should_not have_content("HPV") } |
49 | 63 | end |
50 | 64 | end |
51 | 65 | end |
0 commit comments