Skip to content

Commit ce31259

Browse files
VIA-304 SB Rename VaccineTypes -> VaccineType.
1 parent c4d6b49 commit ce31259

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+211
-211
lines changed

contract/eligibility-api.contract.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NhsNumber, VaccineTypes } from "@src/models/vaccine";
1+
import { NhsNumber, VaccineType } from "@src/models/vaccine";
22
import { getEligibilityForPerson } from "@src/services/eligibility-api/domain/eligibility-filter-service";
33
import {
44
EligibilityErrorTypes,
@@ -35,7 +35,7 @@ describe("EliD API contract", () => {
3535
test.each(successTestCases)(
3636
"$nhsNumber should be $expectedStatus with cohort $expectCohortElement",
3737
async ({ nhsNumber, expectedStatus, expectCohortElement }) => {
38-
const eligibilityForPerson = await getEligibilityForPerson(VaccineTypes.RSV, nhsNumber);
38+
const eligibilityForPerson = await getEligibilityForPerson(VaccineType.RSV, nhsNumber);
3939

4040
expect(Object.keys(eligibilityForPerson).length).toEqual(2);
4141
expect(eligibilityForPerson.eligibility?.status).toEqual(expectedStatus);
@@ -58,7 +58,7 @@ describe("EliD API contract", () => {
5858
];
5959

6060
it.each(failureTestCases)(`$nhsNumber should have error $expectedError `, async ({ nhsNumber, expectedError }) => {
61-
const eligibilityForPerson: EligibilityForPersonType = await getEligibilityForPerson(VaccineTypes.RSV, nhsNumber);
61+
const eligibilityForPerson: EligibilityForPersonType = await getEligibilityForPerson(VaccineType.RSV, nhsNumber);
6262

6363
expect(Object.keys(eligibilityForPerson).length).toEqual(2);
6464
expect(eligibilityForPerson.eligibility).toBeUndefined();

src/_lambda/content-cache-hydrator/content-cache-reader.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
ReadCachedContentResult,
33
readCachedContentForVaccine,
44
} from "@src/_lambda/content-cache-hydrator/content-cache-reader";
5-
import { VaccineInfo, VaccineTypes } from "@src/models/vaccine";
5+
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
66
import { readContentFromCache } from "@src/services/content-api/gateway/content-reader-service";
77
import { InvalidatedCacheError, S3NoSuchKeyError } from "@src/services/content-api/gateway/exceptions";
88
import { AppConfig, configProvider } from "@src/utils/config";
@@ -15,7 +15,7 @@ const mockContentCachePath = "wiremock/__files/";
1515

1616
describe("readCachedContentForVaccine", () => {
1717
const mockCacheFileContents = "mock-cache-file-contents";
18-
const vaccineType = VaccineTypes.RSV;
18+
const vaccineType = VaccineType.RSV;
1919

2020
beforeEach(() => {
2121
(configProvider as jest.Mock).mockImplementation(

src/_lambda/content-cache-hydrator/content-cache-reader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Filename, VaccineInfo, VaccineTypes } from "@src/models/vaccine";
1+
import { Filename, VaccineInfo, VaccineType } from "@src/models/vaccine";
22
import { readContentFromCache } from "@src/services/content-api/gateway/content-reader-service";
33
import { InvalidatedCacheError, S3NoSuchKeyError } from "@src/services/content-api/gateway/exceptions";
44
import { AppConfig, configProvider } from "@src/utils/config";
@@ -11,7 +11,7 @@ export interface ReadCachedContentResult {
1111
cacheContent: string;
1212
}
1313

14-
const readCachedContentForVaccine = async (vaccineType: VaccineTypes): Promise<ReadCachedContentResult> => {
14+
const readCachedContentForVaccine = async (vaccineType: VaccineType): Promise<ReadCachedContentResult> => {
1515
const config: AppConfig = await configProvider();
1616
const cacheFilename: Filename = VaccineInfo[vaccineType].cacheFilename;
1717
let cachedContent: string;

src/_lambda/content-cache-hydrator/content-fetcher.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CONTENT_API_PATH_PREFIX, fetchContentForVaccine } from "@src/_lambda/content-cache-hydrator/content-fetcher";
2-
import { VaccineInfo, VaccineTypes } from "@src/models/vaccine";
2+
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
33
import { AppConfig, configProvider } from "@src/utils/config";
44
import axios from "axios";
55

@@ -24,9 +24,9 @@ describe("fetchContentForVaccine", () => {
2424

2525
it("should fetch content for vaccine", async () => {
2626
(axios.get as jest.Mock).mockResolvedValue({ data: testApiContent });
27-
const actual = await fetchContentForVaccine(VaccineTypes.RSV);
27+
const actual = await fetchContentForVaccine(VaccineType.RSV);
2828
expect(axios.get).toHaveBeenCalledWith(
29-
`${testApiEndpoint}${CONTENT_API_PATH_PREFIX}${VaccineInfo[VaccineTypes.RSV].contentPath}`,
29+
`${testApiEndpoint}${CONTENT_API_PATH_PREFIX}${VaccineInfo[VaccineType.RSV].contentPath}`,
3030
{ headers: { accept: "application/json", apikey: testApiKey }, timeout: 30000 },
3131
);
3232
expect(actual).toBe(JSON.stringify(testApiContent));
@@ -36,6 +36,6 @@ describe("fetchContentForVaccine", () => {
3636
const errorMessage = "Network Error";
3737
(axios.get as jest.Mock).mockRejectedValue(new Error(errorMessage));
3838

39-
await expect(fetchContentForVaccine(VaccineTypes.RSV)).rejects.toThrow(errorMessage);
39+
await expect(fetchContentForVaccine(VaccineType.RSV)).rejects.toThrow(errorMessage);
4040
});
4141
});

src/_lambda/content-cache-hydrator/content-fetcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { VaccineInfo, VaccineTypes } from "@src/models/vaccine";
1+
import { VaccineInfo, VaccineType } from "@src/models/vaccine";
22
import { AppConfig, configProvider } from "@src/utils/config";
33
import { logger } from "@src/utils/logger";
44
import axios, { AxiosError, AxiosResponse } from "axios";
55

66
const log = logger.child({ module: "content-fetcher" });
77
const CONTENT_API_PATH_PREFIX = "nhs-website-content/";
88

9-
const fetchContentForVaccine = async (vaccineType: VaccineTypes): Promise<string> => {
9+
const fetchContentForVaccine = async (vaccineType: VaccineType): Promise<string> => {
1010
const config: AppConfig = await configProvider();
1111

1212
const apiEndpoint: URL = config.CONTENT_API_ENDPOINT;

src/_lambda/content-cache-hydrator/content-writer-service.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
_writeFileS3,
88
writeContentForVaccine,
99
} from "@src/_lambda/content-cache-hydrator/content-writer-service";
10-
import { Filename, VaccineInfo, VaccineTypes } from "@src/models/vaccine";
10+
import { Filename, VaccineInfo, VaccineType } from "@src/models/vaccine";
1111
import { configProvider } from "@src/utils/config";
1212
import { writeFile } from "node:fs/promises";
1313

@@ -79,9 +79,9 @@ describe("Content Writer Service", () => {
7979
}));
8080

8181
it("should return response for rsv vaccine from content cache", async () => {
82-
const vaccine: VaccineTypes = VaccineTypes.RSV;
82+
const vaccine: VaccineType = VaccineType.RSV;
8383
await writeContentForVaccine(vaccine, content);
84-
expect(writeFile).toHaveBeenCalledWith(`${location}${VaccineInfo[VaccineTypes.RSV].cacheFilename}`, content);
84+
expect(writeFile).toHaveBeenCalledWith(`${location}${VaccineInfo[VaccineType.RSV].cacheFilename}`, content);
8585
});
8686
});
8787
});

src/_lambda/content-cache-hydrator/content-writer-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
2-
import { Filename, VaccineInfo, VaccineTypes } from "@src/models/vaccine";
2+
import { Filename, VaccineInfo, VaccineType } from "@src/models/vaccine";
33
import { AppConfig, configProvider } from "@src/utils/config";
44
import { AWS_PRIMARY_REGION } from "@src/utils/constants";
55
import { logger } from "@src/utils/logger";
@@ -37,7 +37,7 @@ const _writeContentToCache = async (
3737
: await writeFile(`${cacheLocation}${cachePath}`, cacheContent);
3838
};
3939

40-
const writeContentForVaccine = async (vaccineType: VaccineTypes, vaccineContent: string) => {
40+
const writeContentForVaccine = async (vaccineType: VaccineType, vaccineContent: string) => {
4141
const config: AppConfig = await configProvider();
4242
const cacheFilename = VaccineInfo[vaccineType].cacheFilename;
4343
await _writeContentToCache(config.CONTENT_CACHE_PATH, cacheFilename, vaccineContent);

src/_lambda/content-cache-hydrator/handler.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { fetchContentForVaccine } from "@src/_lambda/content-cache-hydrator/cont
77
import { writeContentForVaccine } from "@src/_lambda/content-cache-hydrator/content-writer-service";
88
import { _getConfigsThatThrowsOnColdStarts, handler } from "@src/_lambda/content-cache-hydrator/handler";
99
import { invalidateCacheForVaccine } from "@src/_lambda/content-cache-hydrator/invalidate-cache";
10-
import { VaccineTypes } from "@src/models/vaccine";
10+
import { VaccineType } from "@src/models/vaccine";
1111
import { getFilteredContentForVaccine } from "@src/services/content-api/parsers/content-filter-service";
1212
import { getStyledContentForVaccine } from "@src/services/content-api/parsers/content-styling-service";
1313
import { configProvider } from "@src/utils/config";
@@ -40,7 +40,7 @@ const mockInvalidatedCacheReadResult: ReadCachedContentResult = { cacheStatus: "
4040
const mockEmptyCacheReadResult: ReadCachedContentResult = { cacheStatus: "empty", cacheContent: "" };
4141

4242
describe("Lambda Handler", () => {
43-
const numberOfVaccines = Object.values(VaccineTypes).length;
43+
const numberOfVaccines = Object.values(VaccineType).length;
4444
const context = {} as Context;
4545

4646
beforeEach(() => {
@@ -128,7 +128,7 @@ describe("Lambda Handler", () => {
128128
const event = { forceUpdate: true };
129129
await expectHandlerToResolveSuccessfullyWithUndefinedResponse(event, context);
130130

131-
Object.values(VaccineTypes).forEach((vaccineType) => {
131+
Object.values(VaccineType).forEach((vaccineType) => {
132132
expect(writeContentForVaccine).toHaveBeenCalledWith(vaccineType, newContentFromContentAPI);
133133
});
134134
});
@@ -175,7 +175,7 @@ describe("Lambda Handler", () => {
175175

176176
await expectHandlerToResolveSuccessfullyWithUndefinedResponse({}, context);
177177

178-
Object.values(VaccineTypes).forEach((vaccineType) => {
178+
Object.values(VaccineType).forEach((vaccineType) => {
179179
expect(invalidateCacheForVaccine).toHaveBeenCalledWith(vaccineType);
180180
});
181181

@@ -253,8 +253,8 @@ describe("Lambda Handler", () => {
253253
await expect(handler(event, context)).resolves.toBeUndefined();
254254

255255
expect(writeContentForVaccine).toHaveBeenCalledTimes(1);
256-
expect(writeContentForVaccine).toHaveBeenCalledWith(VaccineTypes.RSV, fetchedContentForVaccine);
257-
expect(writeContentForVaccine).not.toHaveBeenCalledWith(VaccineTypes.RSV_PREGNANCY, fetchedContentForVaccine);
256+
expect(writeContentForVaccine).toHaveBeenCalledWith(VaccineType.RSV, fetchedContentForVaccine);
257+
expect(writeContentForVaccine).not.toHaveBeenCalledWith(VaccineType.RSV_PREGNANCY, fetchedContentForVaccine);
258258
};
259259

260260
const expectHydrationToThrowFailureForAllVaccines = async () => {
@@ -269,7 +269,7 @@ describe("Lambda Handler", () => {
269269

270270
await expectHandlerToResolveSuccessfullyWithUndefinedResponse({}, context);
271271

272-
Object.values(VaccineTypes).forEach((vaccineType) => {
272+
Object.values(VaccineType).forEach((vaccineType) => {
273273
expect(writeContentForVaccine).toHaveBeenCalledWith(vaccineType, fetchedContentForVaccine);
274274
expect(invalidateCacheForVaccine).not.toHaveBeenCalledWith(vaccineType);
275275
});
@@ -283,7 +283,7 @@ describe("Lambda Handler", () => {
283283
};
284284

285285
const expectWriteContentToHaveBeenCalledForAllVaccinesWithFetchedContent = (fetchedContentForVaccine: string) => {
286-
Object.values(VaccineTypes).forEach((vaccineType) => {
286+
Object.values(VaccineType).forEach((vaccineType) => {
287287
expect(writeContentForVaccine).toHaveBeenCalledWith(vaccineType, fetchedContentForVaccine);
288288
});
289289
};

src/_lambda/content-cache-hydrator/handler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { vitaContentChangedSinceLastApproved } from "@src/_lambda/content-cache-
33
import { fetchContentForVaccine } from "@src/_lambda/content-cache-hydrator/content-fetcher";
44
import { writeContentForVaccine } from "@src/_lambda/content-cache-hydrator/content-writer-service";
55
import { invalidateCacheForVaccine } from "@src/_lambda/content-cache-hydrator/invalidate-cache";
6-
import { VaccineTypes } from "@src/models/vaccine";
6+
import { VaccineType } from "@src/models/vaccine";
77
import { getFilteredContentForVaccine } from "@src/services/content-api/parsers/content-filter-service";
88
import { getStyledContentForVaccine } from "@src/services/content-api/parsers/content-styling-service";
99
import { VaccinePageContent } from "@src/services/content-api/types";
@@ -16,7 +16,7 @@ import { Context } from "aws-lambda";
1616
const log = logger.child({ module: "content-cache-hydrator" });
1717

1818
const checkContentPassesStylingAndWriteToCache = async (
19-
vaccineType: VaccineTypes,
19+
vaccineType: VaccineType,
2020
content: string,
2121
filteredContent: VaccinePageContent,
2222
): Promise<void> => {
@@ -44,7 +44,7 @@ interface HydrateCacheStatus {
4444
}
4545

4646
async function hydrateCacheForVaccine(
47-
vaccineType: VaccineTypes,
47+
vaccineType: VaccineType,
4848
approvalEnabled: boolean,
4949
forceUpdate: boolean,
5050
): Promise<HydrateCacheStatus> {
@@ -144,7 +144,7 @@ const runContentCacheHydrator = async (event: ContentCacheHydratorEvent) => {
144144

145145
const forceUpdate = typeof event.forceUpdate === "boolean" ? event.forceUpdate : false;
146146

147-
let vaccinesToRunOn: VaccineTypes[];
147+
let vaccinesToRunOn: VaccineType[];
148148
if (event.vaccineToUpdate) {
149149
const vaccineType = getVaccineTypeFromLowercaseString(event.vaccineToUpdate);
150150
if (typeof vaccineType === "undefined") {
@@ -155,7 +155,7 @@ const runContentCacheHydrator = async (event: ContentCacheHydratorEvent) => {
155155
vaccinesToRunOn = [vaccineType];
156156
}
157157
} else {
158-
vaccinesToRunOn = Object.values(VaccineTypes);
158+
vaccinesToRunOn = Object.values(VaccineType);
159159
}
160160

161161
if (forceUpdate) {

src/_lambda/content-cache-hydrator/invalidate-cache.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { writeContentForVaccine } from "@src/_lambda/content-cache-hydrator/content-writer-service";
22
import { invalidateCacheForVaccine } from "@src/_lambda/content-cache-hydrator/invalidate-cache";
3-
import { VaccineTypes } from "@src/models/vaccine";
3+
import { VaccineType } from "@src/models/vaccine";
44
import { INVALIDATED_CONTENT_OVERWRITE_VALUE } from "@src/services/content-api/constants";
55

66
jest.mock("sanitize-data", () => ({ sanitize: jest.fn() }));
@@ -10,7 +10,7 @@ describe("invalidateCacheForVaccine", () => {
1010
it("should call writer service with empty data for given vaccine", async () => {
1111
(writeContentForVaccine as jest.Mock).mockImplementation(() => {});
1212

13-
const vaccine = VaccineTypes.RSV;
13+
const vaccine = VaccineType.RSV;
1414
await invalidateCacheForVaccine(vaccine);
1515

1616
expect(writeContentForVaccine).toHaveBeenCalledWith(vaccine, INVALIDATED_CONTENT_OVERWRITE_VALUE);
@@ -20,6 +20,6 @@ describe("invalidateCacheForVaccine", () => {
2020
const writerError: string = "writer-error";
2121
(writeContentForVaccine as jest.Mock).mockRejectedValue(new Error(writerError));
2222

23-
await expect(invalidateCacheForVaccine(VaccineTypes.RSV)).rejects.toThrow(writerError);
23+
await expect(invalidateCacheForVaccine(VaccineType.RSV)).rejects.toThrow(writerError);
2424
});
2525
});

0 commit comments

Comments
 (0)