Skip to content

Commit

Permalink
fix(*): repair populate axles error if no axles (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
naathanbrown authored Apr 17, 2024
1 parent f69e5c0 commit 64c28d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/models/ministryPlate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export class MinistryPlateDocument extends DocumentModel {
tyreUseCode: techRecord.techRecord_tyreUseCode,
axles: this.populateAxles(
techRecord.techRecord_vehicleType === 'hgv'
? (techRecord.techRecord_axles as HGVAxles[])
: (techRecord.techRecord_axles as TRLAxles[]),
? (techRecord.techRecord_axles as HGVAxles[] ?? [])
: (techRecord.techRecord_axles as TRLAxles[] ?? []),
generateTrlEec,
),
}
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/ministryPlate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ describe('Document Model tests', () => {
expect(document.PLATES_DATA.axles.axle4.weights.gbWeight).toBe('123');
});

it('should not fail if no axles present', () => {
(request.techRecord as TechRecordType<'hgv', 'get'>).techRecord_axles = null as unknown as HGVAxles[];
const document = new MinistryPlateDocument(request);
expect(document.PLATES_DATA.axles.axle1).toStrictEqual({});
});

it('should apply no water mark for prod', () => {
process.env.BRANCH = 'prod';
const document = new MinistryPlateDocument(request);
Expand Down

0 comments on commit 64c28d0

Please sign in to comment.