|
| 1 | +import { VaccineInfo, VaccineType } from "@src/models/vaccine"; |
| 2 | +import { getFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy"; |
| 3 | + |
| 4 | +const apiResponse = JSON.stringify({ |
| 5 | + mainEntityOfPage: [ |
| 6 | + { hasPart: [{ text: "Flu in Pregnancy Vaccine Lead Paragraph (overview)" }] }, |
| 7 | + { hasPart: [{ text: "<p>Why pregnant women are offered the vaccine paragraph</p>" }] }, |
| 8 | + { hasPart: [{ text: "<p>Is the vaccine safe in pregnancy paragraph</p>" }] }, |
| 9 | + { hasPart: [{ text: "<p>When should I have the vaccine paragraph</p>" }] }, |
| 10 | + { hasPart: [{ text: "<p>How to get the vaccine paragraph</p>" }] }, |
| 11 | + { hasPart: [{ text: "paragraph 5" }] }, |
| 12 | + ], |
| 13 | +}); |
| 14 | + |
| 15 | +describe("getFilteredContentForFluInPregnancyVaccine", () => { |
| 16 | + it("should return overview text from lead paragraph mainEntityOfPage object", async () => { |
| 17 | + const expected = { |
| 18 | + overview: { content: "Flu in Pregnancy Vaccine Lead Paragraph (overview)", containsHtml: true }, |
| 19 | + }; |
| 20 | + |
| 21 | + const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse); |
| 22 | + |
| 23 | + expect(pageCopy).toEqual(expect.objectContaining(expected)); |
| 24 | + }); |
| 25 | + |
| 26 | + it("should return all parts for whatVaccineIsFor section", () => { |
| 27 | + const expected = { |
| 28 | + whatVaccineIsFor: { |
| 29 | + headline: "Why pregnant women are offered the vaccine", |
| 30 | + subsections: [ |
| 31 | + { |
| 32 | + type: "simpleElement", |
| 33 | + headline: "", |
| 34 | + name: "markdown", |
| 35 | + text: "<p>Why pregnant women are offered the vaccine paragraph</p>", |
| 36 | + }, |
| 37 | + ], |
| 38 | + }, |
| 39 | + }; |
| 40 | + |
| 41 | + const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse); |
| 42 | + |
| 43 | + expect(pageCopy).toEqual(expect.objectContaining(expected)); |
| 44 | + }); |
| 45 | + |
| 46 | + it("should return all parts for whoVaccineIsFor section", () => { |
| 47 | + const expected = { |
| 48 | + whoVaccineIsFor: { |
| 49 | + headline: "Is the vaccine safe in pregnancy?", |
| 50 | + subsections: [ |
| 51 | + { |
| 52 | + type: "simpleElement", |
| 53 | + headline: "", |
| 54 | + name: "markdown", |
| 55 | + text: "<p>Is the vaccine safe in pregnancy paragraph</p>", |
| 56 | + }, |
| 57 | + ], |
| 58 | + }, |
| 59 | + }; |
| 60 | + |
| 61 | + const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse); |
| 62 | + |
| 63 | + expect(pageCopy).toEqual(expect.objectContaining(expected)); |
| 64 | + }); |
| 65 | + |
| 66 | + it("should return all parts for howToGetVaccine section", () => { |
| 67 | + const expected = { |
| 68 | + howToGetVaccine: { |
| 69 | + headline: "How to get the vaccine", |
| 70 | + subsections: [ |
| 71 | + { |
| 72 | + type: "simpleElement", |
| 73 | + headline: "", |
| 74 | + name: "markdown", |
| 75 | + text: "<p>How to get the vaccine paragraph</p>", |
| 76 | + }, |
| 77 | + ], |
| 78 | + }, |
| 79 | + }; |
| 80 | + |
| 81 | + const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse); |
| 82 | + |
| 83 | + expect(pageCopy).toEqual(expect.objectContaining(expected)); |
| 84 | + }); |
| 85 | + |
| 86 | + it("should return all parts for vaccineSideEffects section", () => { |
| 87 | + const expected = { |
| 88 | + vaccineSideEffects: { |
| 89 | + headline: "When should I have the vaccine?", |
| 90 | + subsections: [ |
| 91 | + { |
| 92 | + type: "simpleElement", |
| 93 | + headline: "", |
| 94 | + name: "markdown", |
| 95 | + text: "<p>When should I have the vaccine paragraph</p>", |
| 96 | + }, |
| 97 | + ], |
| 98 | + }, |
| 99 | + }; |
| 100 | + |
| 101 | + const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse); |
| 102 | + |
| 103 | + expect(pageCopy).toEqual(expect.objectContaining(expected)); |
| 104 | + }); |
| 105 | + |
| 106 | + it("should include nhs webpage link to vaccine info", () => { |
| 107 | + const expected = { |
| 108 | + webpageLink: VaccineInfo[VaccineType.WHOOPING_COUGH].nhsWebpageLink, |
| 109 | + }; |
| 110 | + |
| 111 | + const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse); |
| 112 | + |
| 113 | + expect(pageCopy).toEqual(expect.objectContaining(expected)); |
| 114 | + }); |
| 115 | +}); |
0 commit comments