Skip to content

Commit

Permalink
fix(cb2-10343): correct logic for determining whether to autopopulate… (
Browse files Browse the repository at this point in the history
#1347)

* fix(cb2-10343): correct logic for determining whether to autopopulate able to carry dangerous goods

* fix(cb2-10343): fix broken test
  • Loading branch information
pbardy2000 authored Jan 4, 2024
1 parent f26be6f commit b413e52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/app/forms/custom-sections/adr/adr.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,5 @@ describe('AdrComponent', () => {
component.ngOnInit();
expect(spy).toHaveBeenCalled();
});
it('should populate the tank statement select property', () => {
const spy = jest.spyOn(component.adrService, 'determineTankStatementSelect');
component.ngOnInit();
expect(spy).toHaveBeenCalled();
});
});
});
4 changes: 3 additions & 1 deletion src/app/forms/custom-sections/adr/adr.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export class AdrComponent implements OnInit, OnDestroy {
this.template = this.isReviewScreen ? AdrSummaryTemplate : AdrTemplate;
this.form = this.dfs.createForm(this.template, this.techRecord) as CustomFormGroup;
this.techRecord.techRecord_adrDetails_dangerousGoods = this.adrService.carriesDangerousGoods(this.techRecord);
this.techRecord.techRecord_adrDetails_tank_tankDetails_tankStatement_select = this.adrService.determineTankStatementSelect(this.techRecord);
if (this.techRecord.techRecord_adrDetails_dangerousGoods) {
this.techRecord.techRecord_adrDetails_tank_tankDetails_tankStatement_select = this.adrService.determineTankStatementSelect(this.techRecord);
}
this.handleSubmit();
}

Expand Down
5 changes: 4 additions & 1 deletion src/app/services/adr/adr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export class AdrService {

carriesDangerousGoods(techRecord: TechRecordType<'hgv' | 'lgv' | 'trl'>) {
return techRecord.techRecord_adrDetails_dangerousGoods
|| Boolean(Object.keys(techRecord).find((key) => key !== 'techRecord_adrDetails_dangerousGoods' && key.includes('adrDetails')));
|| (techRecord.techRecord_adrDetails_dangerousGoods !== false && Boolean(Object.keys(techRecord).find((key) =>
key !== 'techRecord_adrDetails_dangerousGoods'
&& key.includes('adrDetails')
&& techRecord[key as keyof TechRecordType<'hgv' | 'lgv' | 'trl'>] != null)));
}
}

0 comments on commit b413e52

Please sign in to comment.