Skip to content

Commit

Permalink
Added function to get label for driving faults
Browse files Browse the repository at this point in the history
  • Loading branch information
gittins7 authored and RLCorp committed Apr 22, 2024
1 parent ccdf206 commit e9c6ce7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ describe('VehicleChecksComponent', () => {
});
});

describe('drivingFaultsLabel', () => {
it('should return "driving fault" when count is 1', () => {
const result = component.drivingFaultsLabel(1);
expect(result).toEqual('driving fault');
});

it('should return "driving faults" when count is greater than 1', () => {
const result = component.drivingFaultsLabel(2);
expect(result).toEqual('driving faults');
});
});

describe('invalid', () => {
beforeEach(() => {
store$.dispatch(StartTest(12345, TestCategory.C));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
[count]="vehicleChecksScore.drivingFaults + (safetyQuestionsScore?.drivingFaults || 0)"
>
</driving-faults-badge>
<span class="vehicle-checks-result-text" id="vehicle-check-df-label">driving faults</span>
<span class="vehicle-checks-result-text" id="vehicle-check-df-label"
>{{drivingFaultsLabel(vehicleChecksScore.drivingFaults + (safetyQuestionsScore?.drivingFaults || 0))}}</span
>
</ion-row>
</ion-col>
<ion-col size="47" *ngIf="everyQuestionHasOutcome()" class="see-answer-link-container ion-padding-end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ export class VehicleChecksComponent implements OnChanges {
return this.everyQuestionHasOutcome() ? null : this.incompleteVehicleChecks();
}

drivingFaultsLabel(count: number): string {
let label: string = 'driving fault';
if(count > 1) {
label = 'driving faults'
} return label;
}

get invalid(): boolean {
return !this.formControl.valid && this.formControl.dirty;
}
Expand Down

0 comments on commit e9c6ce7

Please sign in to comment.