Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mes-9932-noNonNullAssertion #1789

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactored displayRegistration
  • Loading branch information
RLCorp committed Oct 7, 2024
commit e5dcd5e6ce91bb295d16683c934dd8eb6f4ff2bd
Original file line number Diff line number Diff line change
Expand Up @@ -424,41 +424,33 @@ describe('VehicleDetailsCardComponent', () => {
});
});

describe('displayRegistration', () => {
it('should return the correct value if the category is ADI3', () => {
spyOn(component, 'isADI3').and.returnValue(true);
spyOnProperty(component, 'registrationNumber').and.returnValue(undefined);
spyOnProperty(component, 'shouldShowDimensions').and.returnValue(false);
component.vehicleDetails = undefined;
expect(component.displayRegistration).toBeTruthy();
fdescribe('displayRegistration', () => {
it('should return true if category is ADI3', () => {
component.category = TestCategory.ADI3;
expect(component.displayRegistration()).toEqual(true);
});
it('should return the correct value if the registration number is present', () => {
spyOn(component, 'isADI3').and.returnValue(false);
spyOnProperty(component, 'registrationNumber').and.returnValue('1');
spyOnProperty(component, 'shouldShowDimensions').and.returnValue(false);
component.vehicleDetails = undefined;
expect(component.displayRegistration).toBeTruthy();

it('should return true if instructorRegistrationNumber is not undefined', () => {
spyOnProperty(component, 'instructorRegistrationNumber').and.returnValue(12345);
expect(component.displayRegistration()).toEqual(true);
});
it('should return the correct value if should show dimensions is true', () => {
spyOn(component, 'isADI3').and.returnValue(false);
spyOnProperty(component, 'registrationNumber').and.returnValue(undefined);

it('should return true if shouldShowDimensions is true', () => {
spyOnProperty(component, 'shouldShowDimensions').and.returnValue(true);
component.vehicleDetails = undefined;
expect(component.displayRegistration).toBeTruthy();
expect(component.displayRegistration()).toEqual(true);
});
it('should return the correct value if vehicle details is defined', () => {
spyOn(component, 'isADI3').and.returnValue(false);
spyOnProperty(component, 'registrationNumber').and.returnValue(undefined);
spyOnProperty(component, 'shouldShowDimensions').and.returnValue(false);
component.vehicleDetails = ['d', 'e', 'f', 'i', 'n', 'e', 'd'];
expect(component.displayRegistration).toBeTruthy();

it('should return true if vehicleDetails is not undefined', () => {
component.vehicleDetails = ['detail1', 'detail2'];
expect(component.displayRegistration()).toEqual(true);
});
it('should return the correct value if nothing is defined', () => {
spyOn(component, 'isADI3').and.returnValue(false);
spyOnProperty(component, 'registrationNumber').and.returnValue(undefined);

it('should return false if all conditions are false or undefined', () => {
spyOnProperty(component, 'instructorRegistrationNumber').and.returnValue(undefined);
spyOnProperty(component, 'shouldShowDimensions').and.returnValue(false);
component.vehicleDetails = undefined;
expect(component.displayRegistration).toBeTruthy();
component.category = TestCategory.B;
expect(component.displayRegistration()).toEqual(false);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ export class VehicleDetailsCardComponent {
displayRegistration() {
return (
this.isADI3() ||
!this.instructorRegistrationNumber === undefined ||
this.instructorRegistrationNumber !== undefined ||
this.shouldShowDimensions ||
!this.vehicleDetails === undefined
this.vehicleDetails !== undefined
);
}

Expand Down