Skip to content

Commit

Permalink
feat(DTFS2-7052): actioning PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
avaitonis committed Apr 25, 2024
1 parent 3e215d7 commit 7d15b07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/modules/geospatial/dto/get-addresses-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export class GetAddressesResponseItem {
readonly addressLine3: string | null;

@ApiProperty({
description: 'Locality, Town',
description: 'Locality or town',
example: GEOSPATIAL.EXAMPLES.LOCALITY,
nullable: true,
})
readonly locality: string | null;

Expand Down
14 changes: 7 additions & 7 deletions src/modules/geospatial/geospatial.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ describe('GeospatialService', () => {

let service: GeospatialService;
let configServiceGet: jest.Mock;
let informaticaServiceGetAddressesByPostcode: jest.Mock;
let ordnanceSurveyServiceGetAddressesByPostcode: jest.Mock;

beforeEach(() => {
const configService = new ConfigService();
configServiceGet = jest.fn().mockReturnValue({ key: valueGenerator.word() });
configService.get = configServiceGet;

informaticaServiceGetAddressesByPostcode = jest.fn();
ordnanceSurveyServiceGetAddressesByPostcode = jest.fn();
const ordnanceSurveyService = new OrdnanceSurveyService(null, configService);
ordnanceSurveyService.getAddressesByPostcode = informaticaServiceGetAddressesByPostcode;
ordnanceSurveyService.getAddressesByPostcode = ordnanceSurveyServiceGetAddressesByPostcode;
resetAllWhenMocks();

service = new GeospatialService(ordnanceSurveyService);
Expand All @@ -41,23 +41,23 @@ describe('GeospatialService', () => {
const postcode = getAddressByPostcodeResponse[0][0].postalCode;

it('returns a single address from the backend service', async () => {
when(informaticaServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(getAddressOrdnanceSurveyResponse[0]);
when(ordnanceSurveyServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(getAddressOrdnanceSurveyResponse[0]);

const response = await service.getAddressesByPostcode(postcode);

expect(response).toEqual(getAddressByPostcodeResponse[0]);
});

it('returns multiple addressess from the backend service', async () => {
when(informaticaServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(getAddressOrdnanceSurveyMultipleResponse);
when(ordnanceSurveyServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(getAddressOrdnanceSurveyMultipleResponse);

const response = await service.getAddressesByPostcode(postcode);

expect(response).toEqual(getAddressByPostcodeMultipleResponse);
});

it('can handle empty backend response', async () => {
when(informaticaServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(getAddressOrdnanceSurveyEmptyResponse[0]);
when(ordnanceSurveyServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(getAddressOrdnanceSurveyEmptyResponse[0]);

const response = await service.getAddressesByPostcode(postcode);

Expand All @@ -68,7 +68,7 @@ describe('GeospatialService', () => {
const [modifiedOrdnanceSurveyResponse] = getAddressOrdnanceSurveyResponse;
modifiedOrdnanceSurveyResponse.results[0].DPA.BUILDING_NUMBER = null;
const address = modifiedOrdnanceSurveyResponse.results[0].DPA;
when(informaticaServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(modifiedOrdnanceSurveyResponse);
when(ordnanceSurveyServiceGetAddressesByPostcode).calledWith(postcode).mockResolvedValueOnce(modifiedOrdnanceSurveyResponse);

const response = await service.getAddressesByPostcode(postcode);

Expand Down
3 changes: 0 additions & 3 deletions src/modules/mdm.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Module } from '@nestjs/common';
import { AuthModule } from '@ukef/auth/auth.module';
import { DatabaseModule } from '@ukef/database/database.module';
import { OrdnanceSurveyModule } from '@ukef/helper-modules/ordnance-survey/ordnance-survey.module';
import { CurrenciesModule } from '@ukef/modules/currencies/currencies.module';
import { CustomersModule } from '@ukef/modules/customers/customers.module';
import { ExposurePeriodModule } from '@ukef/modules/exposure-period/exposure-period.module';
Expand All @@ -28,7 +27,6 @@ import { YieldRatesModule } from '@ukef/modules/yield-rates/yield-rates.module';
PremiumSchedulesModule,
SectorIndustriesModule,
YieldRatesModule,
OrdnanceSurveyModule,
GeospatialModule,
],
exports: [
Expand All @@ -44,7 +42,6 @@ import { YieldRatesModule } from '@ukef/modules/yield-rates/yield-rates.module';
PremiumSchedulesModule,
SectorIndustriesModule,
YieldRatesModule,
OrdnanceSurveyModule,
GeospatialModule,
],
})
Expand Down

0 comments on commit 7d15b07

Please sign in to comment.