Skip to content

Commit a66124f

Browse files
VIA-618 SB Rename filteredContentBuilder functions.
1 parent a1f53e2 commit a66124f

12 files changed

+62
-62
lines changed

src/services/content-api/parsers/content-filter-service.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {
99
_removeExcludedHyperlinks,
1010
getFilteredContentForVaccine,
1111
} from "@src/services/content-api/parsers/content-filter-service";
12-
import { getFilteredContentForFluForChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-children";
13-
import { getFilteredContentForFluForSchoolAgedChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-school-aged-children";
14-
import { getFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy";
15-
import { getFilteredContentForFluVaccine } from "@src/services/content-api/parsers/custom/flu-vaccine";
16-
import { getFilteredContentForWhoopingCoughVaccine } from "@src/services/content-api/parsers/custom/whooping-cough";
12+
import { buildFilteredContentForFluForChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-children";
13+
import { buildFilteredContentForFluForSchoolAgedChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-school-aged-children";
14+
import { buildFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy";
15+
import { buildFilteredContentForFluVaccine } from "@src/services/content-api/parsers/custom/flu-vaccine";
16+
import { buildFilteredContentForWhoopingCoughVaccine } from "@src/services/content-api/parsers/custom/whooping-cough";
1717
import {
1818
ContentApiVaccineResponse,
1919
HeadingWithTypedContent,
@@ -740,15 +740,15 @@ describe("Content Filter", () => {
740740

741741
getFilteredContentForVaccine(VaccineType.WHOOPING_COUGH, mockApiContent);
742742

743-
expect(getFilteredContentForWhoopingCoughVaccine).toHaveBeenCalledWith(mockApiContent);
743+
expect(buildFilteredContentForWhoopingCoughVaccine).toHaveBeenCalledWith(mockApiContent);
744744
});
745745

746746
it("should call getFilteredContentForFluVaccine for flu vaccine", () => {
747747
const mockApiContent = "testContent";
748748

749749
getFilteredContentForVaccine(VaccineType.FLU_FOR_ADULTS, mockApiContent);
750750

751-
expect(getFilteredContentForFluVaccine).toHaveBeenCalledWith(mockApiContent);
751+
expect(buildFilteredContentForFluVaccine).toHaveBeenCalledWith(mockApiContent);
752752
});
753753

754754
it("should return standard vaccine content and additional content for COVID-19 vaccine", () => {
@@ -776,22 +776,22 @@ describe("Content Filter", () => {
776776

777777
getFilteredContentForVaccine(VaccineType.FLU_IN_PREGNANCY, mockApiContent);
778778

779-
expect(getFilteredContentForFluInPregnancyVaccine).toHaveBeenCalledWith(mockApiContent);
779+
expect(buildFilteredContentForFluInPregnancyVaccine).toHaveBeenCalledWith(mockApiContent);
780780
});
781781

782782
it("should call getFilteredContentForFluForChildrenVaccine for flu for children vaccine", () => {
783783
const mockApiContent = "testContent";
784784

785785
getFilteredContentForVaccine(VaccineType.FLU_FOR_CHILDREN, mockApiContent);
786786

787-
expect(getFilteredContentForFluForChildrenVaccine).toHaveBeenCalledWith(mockApiContent);
787+
expect(buildFilteredContentForFluForChildrenVaccine).toHaveBeenCalledWith(mockApiContent);
788788
});
789789

790790
it("should return standard vaccine content and recommendation for school aged children's flu vaccine", () => {
791791
const mockApiContent = "testContent";
792792

793793
getFilteredContentForVaccine(VaccineType.FLU_FOR_SCHOOL_AGED_CHILDREN, mockApiContent);
794-
expect(getFilteredContentForFluForSchoolAgedChildrenVaccine).toHaveBeenCalledWith(mockApiContent);
794+
expect(buildFilteredContentForFluForSchoolAgedChildrenVaccine).toHaveBeenCalledWith(mockApiContent);
795795
});
796796
});
797797
});

src/services/content-api/parsers/content-filter-service.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { VaccineType } from "@src/models/vaccine";
22
import { getAdditionalContentForCovid19Vaccine } from "@src/services/content-api/parsers/custom/covid-19";
3-
import { getFilteredContentForFluForChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-children";
4-
import { getFilteredContentForFluForSchoolAgedChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-school-aged-children";
5-
import { getFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy";
6-
import { getFilteredContentForFluVaccine } from "@src/services/content-api/parsers/custom/flu-vaccine";
7-
import { getFilteredContentForWhoopingCoughVaccine } from "@src/services/content-api/parsers/custom/whooping-cough";
3+
import { buildFilteredContentForFluForChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-children";
4+
import { buildFilteredContentForFluForSchoolAgedChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-school-aged-children";
5+
import { buildFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy";
6+
import { buildFilteredContentForFluVaccine } from "@src/services/content-api/parsers/custom/flu-vaccine";
7+
import { buildFilteredContentForWhoopingCoughVaccine } from "@src/services/content-api/parsers/custom/whooping-cough";
88
import {
99
ContentApiVaccineResponse,
1010
HasPartSubsection,
@@ -212,25 +212,25 @@ function _extractHeadlineForContraindicationsAspect(content: ContentApiVaccineRe
212212

213213
const getFilteredContentForVaccine = (vaccineType: VaccineType, apiContent: string): VaccinePageContent => {
214214
const filteredContentBuilders = new Map([
215-
[VaccineType.WHOOPING_COUGH, getFilteredContentForWhoopingCoughVaccine],
216-
[VaccineType.FLU_IN_PREGNANCY, getFilteredContentForFluInPregnancyVaccine],
217-
[VaccineType.FLU_FOR_ADULTS, getFilteredContentForFluVaccine],
218-
[VaccineType.FLU_FOR_CHILDREN, getFilteredContentForFluForChildrenVaccine],
219-
[VaccineType.FLU_FOR_SCHOOL_AGED_CHILDREN, getFilteredContentForFluForSchoolAgedChildrenVaccine],
215+
[VaccineType.WHOOPING_COUGH, buildFilteredContentForWhoopingCoughVaccine],
216+
[VaccineType.FLU_IN_PREGNANCY, buildFilteredContentForFluInPregnancyVaccine],
217+
[VaccineType.FLU_FOR_ADULTS, buildFilteredContentForFluVaccine],
218+
[VaccineType.FLU_FOR_CHILDREN, buildFilteredContentForFluForChildrenVaccine],
219+
[VaccineType.FLU_FOR_SCHOOL_AGED_CHILDREN, buildFilteredContentForFluForSchoolAgedChildrenVaccine],
220220
[
221221
VaccineType.COVID_19,
222222
(apiContent) => {
223-
const standardVaccineContent = getFilteredContentForStandardVaccine(apiContent);
223+
const standardVaccineContent = buildFilteredContentForStandardVaccine(apiContent);
224224
const additionalCovid19VaccineContent = getAdditionalContentForCovid19Vaccine();
225225
return { ...standardVaccineContent, ...additionalCovid19VaccineContent };
226226
},
227227
],
228228
]);
229-
const filteredContentBuilder = filteredContentBuilders.get(vaccineType) || getFilteredContentForStandardVaccine;
229+
const filteredContentBuilder = filteredContentBuilders.get(vaccineType) || buildFilteredContentForStandardVaccine;
230230
return filteredContentBuilder(apiContent);
231231
};
232232

233-
const getFilteredContentForStandardVaccine = (apiContent: string): VaccinePageContent => {
233+
const buildFilteredContentForStandardVaccine = (apiContent: string): VaccinePageContent => {
234234
const content: ContentApiVaccineResponse = JSON.parse(apiContent);
235235

236236
const overview: Overview = { content: _extractDescriptionForVaccine(content, "lead paragraph"), containsHtml: false };
@@ -284,7 +284,7 @@ const getFilteredContentForStandardVaccine = (apiContent: string): VaccinePageCo
284284

285285
export {
286286
getFilteredContentForVaccine,
287-
getFilteredContentForStandardVaccine,
287+
buildFilteredContentForStandardVaccine,
288288
_findAspect,
289289
_hasHealthAspect,
290290
_extractPartsForAspect,

src/services/content-api/parsers/custom/flu-for-children.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getFilteredContentForFluForChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-children";
1+
import { buildFilteredContentForFluForChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-children";
22
import { genericVaccineContentAPIResponse } from "@test-data/content-api/data";
33

44
describe("getFilteredContentForFluVaccine", () => {
@@ -7,7 +7,7 @@ describe("getFilteredContentForFluVaccine", () => {
77
overview: { content: "Generic Vaccine Lead Paragraph (overview)", containsHtml: false },
88
};
99

10-
const pageCopy = getFilteredContentForFluForChildrenVaccine(JSON.stringify(genericVaccineContentAPIResponse));
10+
const pageCopy = buildFilteredContentForFluForChildrenVaccine(JSON.stringify(genericVaccineContentAPIResponse));
1111

1212
expect(pageCopy).toEqual(expect.objectContaining(expectedOverview));
1313
});
@@ -21,7 +21,7 @@ describe("getFilteredContentForFluVaccine", () => {
2121
},
2222
};
2323

24-
const pageCopy = getFilteredContentForFluForChildrenVaccine(JSON.stringify(genericVaccineContentAPIResponse));
24+
const pageCopy = buildFilteredContentForFluForChildrenVaccine(JSON.stringify(genericVaccineContentAPIResponse));
2525

2626
expect(pageCopy).toEqual(expect.objectContaining(expected));
2727
});
@@ -34,7 +34,7 @@ describe("getFilteredContentForFluVaccine", () => {
3434
},
3535
};
3636

37-
const pageCopy = getFilteredContentForFluForChildrenVaccine(JSON.stringify(genericVaccineContentAPIResponse));
37+
const pageCopy = buildFilteredContentForFluForChildrenVaccine(JSON.stringify(genericVaccineContentAPIResponse));
3838

3939
expect(pageCopy).toEqual(expect.objectContaining(expected));
4040
});

src/services/content-api/parsers/custom/flu-for-children.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service";
1+
import { buildFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service";
22
import { HeadingWithContent, HeadingWithTypedContent, VaccinePageContent } from "@src/services/content-api/types";
33

4-
export const getFilteredContentForFluForChildrenVaccine = (apiContent: string): VaccinePageContent => {
5-
const standardFilteredContent = getFilteredContentForStandardVaccine(apiContent);
4+
export const buildFilteredContentForFluForChildrenVaccine = (apiContent: string): VaccinePageContent => {
5+
const standardFilteredContent = buildFilteredContentForStandardVaccine(apiContent);
66

77
const callout: HeadingWithTypedContent = {
88
heading: "Booking service closed",

src/services/content-api/parsers/custom/flu-for-school-aged-children.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getFilteredContentForFluForSchoolAgedChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-school-aged-children";
1+
import { buildFilteredContentForFluForSchoolAgedChildrenVaccine } from "@src/services/content-api/parsers/custom/flu-for-school-aged-children";
22
import { genericVaccineContentAPIResponse } from "@test-data/content-api/data";
33

44
describe("getFilteredContentForFluVaccine", () => {
@@ -7,15 +7,15 @@ describe("getFilteredContentForFluVaccine", () => {
77
overview: { content: "Generic Vaccine Lead Paragraph (overview)", containsHtml: false },
88
};
99

10-
const pageCopy = getFilteredContentForFluForSchoolAgedChildrenVaccine(
10+
const pageCopy = buildFilteredContentForFluForSchoolAgedChildrenVaccine(
1111
JSON.stringify(genericVaccineContentAPIResponse),
1212
);
1313

1414
expect(pageCopy).toEqual(expect.objectContaining(expectedOverview));
1515
});
1616

1717
it("should set the standard vaccine content", async () => {
18-
const pageCopy = getFilteredContentForFluForSchoolAgedChildrenVaccine(
18+
const pageCopy = buildFilteredContentForFluForSchoolAgedChildrenVaccine(
1919
JSON.stringify(genericVaccineContentAPIResponse),
2020
);
2121

@@ -34,7 +34,7 @@ describe("getFilteredContentForFluVaccine", () => {
3434
},
3535
};
3636

37-
const pageCopy = getFilteredContentForFluForSchoolAgedChildrenVaccine(
37+
const pageCopy = buildFilteredContentForFluForSchoolAgedChildrenVaccine(
3838
JSON.stringify(genericVaccineContentAPIResponse),
3939
);
4040

src/services/content-api/parsers/custom/flu-for-school-aged-children.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service";
1+
import { buildFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service";
22
import { HeadingWithContent, VaccinePageContent } from "@src/services/content-api/types";
33

4-
export const getFilteredContentForFluForSchoolAgedChildrenVaccine = (apiContent: string): VaccinePageContent => {
5-
const standardFilteredContent = getFilteredContentForStandardVaccine(apiContent);
4+
export const buildFilteredContentForFluForSchoolAgedChildrenVaccine = (apiContent: string): VaccinePageContent => {
5+
const standardFilteredContent = buildFilteredContentForStandardVaccine(apiContent);
66

77
const recommendation: HeadingWithContent = {
88
heading: "The flu vaccine is recommended for children who:",

src/services/content-api/parsers/custom/flu-in-pregnancy.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
2-
import { getFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy";
2+
import { buildFilteredContentForFluInPregnancyVaccine } from "@src/services/content-api/parsers/custom/flu-in-pregnancy";
33

44
const apiResponse = JSON.stringify({
55
mainEntityOfPage: [
@@ -28,7 +28,7 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
2828
},
2929
};
3030

31-
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
31+
const pageCopy = buildFilteredContentForFluInPregnancyVaccine(apiResponse);
3232

3333
expect(pageCopy).toEqual(expect.objectContaining(expected));
3434
});
@@ -48,7 +48,7 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
4848
},
4949
};
5050

51-
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
51+
const pageCopy = buildFilteredContentForFluInPregnancyVaccine(apiResponse);
5252

5353
expect(pageCopy).toEqual(expect.objectContaining(expected));
5454
});
@@ -68,7 +68,7 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
6868
},
6969
};
7070

71-
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
71+
const pageCopy = buildFilteredContentForFluInPregnancyVaccine(apiResponse);
7272

7373
expect(pageCopy).toEqual(expect.objectContaining(expected));
7474
});
@@ -88,7 +88,7 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
8888
},
8989
};
9090

91-
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
91+
const pageCopy = buildFilteredContentForFluInPregnancyVaccine(apiResponse);
9292

9393
expect(pageCopy).toEqual(expect.objectContaining(expected));
9494
});
@@ -98,7 +98,7 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
9898
webpageLink: VaccineInfo[VaccineType.WHOOPING_COUGH].nhsWebpageLink,
9999
};
100100

101-
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
101+
const pageCopy = buildFilteredContentForFluInPregnancyVaccine(apiResponse);
102102

103103
expect(pageCopy).toEqual(expect.objectContaining(expected));
104104
});
@@ -112,7 +112,7 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
112112
},
113113
};
114114

115-
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
115+
const pageCopy = buildFilteredContentForFluInPregnancyVaccine(apiResponse);
116116

117117
expect(pageCopy).toEqual(expect.objectContaining(expected));
118118
});
@@ -125,7 +125,7 @@ describe("getFilteredContentForFluInPregnancyVaccine", () => {
125125
},
126126
};
127127

128-
const pageCopy = getFilteredContentForFluInPregnancyVaccine(apiResponse);
128+
const pageCopy = buildFilteredContentForFluInPregnancyVaccine(apiResponse);
129129

130130
expect(pageCopy).toEqual(expect.objectContaining(expected));
131131
});

src/services/content-api/parsers/custom/flu-in-pregnancy.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
VaccinePageSection,
88
} from "@src/services/content-api/types";
99

10-
export const getFilteredContentForFluInPregnancyVaccine = (apiContent: string): VaccinePageContent => {
10+
export const buildFilteredContentForFluInPregnancyVaccine = (apiContent: string): VaccinePageContent => {
1111
const content: ContentApiVaccineResponse = JSON.parse(apiContent);
1212

1313
const paragraphs: string[] = content.mainEntityOfPage

src/services/content-api/parsers/custom/flu-vaccine.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getFilteredContentForFluVaccine } from "@src/services/content-api/parsers/custom/flu-vaccine";
1+
import { buildFilteredContentForFluVaccine } from "@src/services/content-api/parsers/custom/flu-vaccine";
22
import { genericVaccineContentAPIResponse } from "@test-data/content-api/data";
33

44
describe("getFilteredContentForFluVaccine", () => {
@@ -7,7 +7,7 @@ describe("getFilteredContentForFluVaccine", () => {
77
overview: { content: "Generic Vaccine Lead Paragraph (overview)", containsHtml: false },
88
};
99

10-
const pageCopy = getFilteredContentForFluVaccine(JSON.stringify(genericVaccineContentAPIResponse));
10+
const pageCopy = buildFilteredContentForFluVaccine(JSON.stringify(genericVaccineContentAPIResponse));
1111

1212
expect(pageCopy).toEqual(expect.objectContaining(expectedOverview));
1313
});
@@ -21,7 +21,7 @@ describe("getFilteredContentForFluVaccine", () => {
2121
},
2222
};
2323

24-
const pageCopy = getFilteredContentForFluVaccine(JSON.stringify(genericVaccineContentAPIResponse));
24+
const pageCopy = buildFilteredContentForFluVaccine(JSON.stringify(genericVaccineContentAPIResponse));
2525

2626
expect(pageCopy).toEqual(expect.objectContaining(expected));
2727
});
@@ -40,7 +40,7 @@ describe("getFilteredContentForFluVaccine", () => {
4040
},
4141
};
4242

43-
const pageCopy = getFilteredContentForFluVaccine(JSON.stringify(genericVaccineContentAPIResponse));
43+
const pageCopy = buildFilteredContentForFluVaccine(JSON.stringify(genericVaccineContentAPIResponse));
4444

4545
expect(pageCopy).toEqual(expect.objectContaining(expected));
4646
});

src/services/content-api/parsers/custom/flu-vaccine.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service";
1+
import { buildFilteredContentForStandardVaccine } from "@src/services/content-api/parsers/content-filter-service";
22
import { HeadingWithContent, HeadingWithTypedContent, VaccinePageContent } from "@src/services/content-api/types";
33

4-
export const getFilteredContentForFluVaccine = (apiContent: string): VaccinePageContent => {
5-
const standardFilteredContent = getFilteredContentForStandardVaccine(apiContent);
4+
export const buildFilteredContentForFluVaccine = (apiContent: string): VaccinePageContent => {
5+
const standardFilteredContent = buildFilteredContentForStandardVaccine(apiContent);
66

77
const callout: HeadingWithTypedContent = {
88
heading: "Booking service closed",

0 commit comments

Comments
 (0)