Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
RLCorp committed Sep 23, 2024
1 parent f054f3b commit f785138
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ReactiveFormsModule, UntypedFormControl, UntypedFormGroup, Validators }
import { AppModule } from '@app/app.module';
import { IonicModule } from '@ionic/angular';
import { Store } from '@ngrx/store';
import { MotHistoryWithStatus } from '@providers/mot-history-api/mot-history-api.service';
import { MotStatusCodes } from '@providers/mot-history-api/mot-interfaces';
import { ConnectionStatus } from '@providers/network-state/network-state';
import { HttpStatusCodes } from '@shared/models/http-status-codes';
Expand Down Expand Up @@ -178,32 +179,32 @@ describe('VehicleRegistrationComponent', () => {
});
describe('isSearchFailed', () => {
it('should return true if status is UNDEFINED', () => {
component.motData.status = HttpStatusCodes.UNDEFINED.toString();
component.motData = { status: HttpStatusCodes.UNDEFINED.toString() } as MotHistoryWithStatus;
expect(component.isSearchFailed()).toEqual(true);
});

it('should return true if status is INTERNAL_SERVER_ERROR', () => {
component.motData.status = HttpStatusCodes.INTERNAL_SERVER_ERROR.toString();
component.motData = { status: HttpStatusCodes.INTERNAL_SERVER_ERROR.toString() } as MotHistoryWithStatus;
expect(component.isSearchFailed()).toEqual(true);
});

it('should return true if status is BAD_GATEWAY', () => {
component.motData.status = HttpStatusCodes.BAD_GATEWAY.toString();
component.motData = { status: HttpStatusCodes.BAD_GATEWAY.toString() } as MotHistoryWithStatus;
expect(component.isSearchFailed()).toEqual(true);
});

it('should return true if status is SERVICE_UNAVAILABLE', () => {
component.motData.status = HttpStatusCodes.SERVICE_UNAVAILABLE.toString();
component.motData = { status: HttpStatusCodes.SERVICE_UNAVAILABLE.toString() } as MotHistoryWithStatus;
expect(component.isSearchFailed()).toEqual(true);
});

it('should return true if status is GATEWAY_TIMEOUT', () => {
component.motData.status = HttpStatusCodes.GATEWAY_TIMEOUT.toString();
component.motData = { status: HttpStatusCodes.GATEWAY_TIMEOUT.toString() } as MotHistoryWithStatus;
expect(component.isSearchFailed()).toEqual(true);
});

it('should return false if status is a listed status code', () => {
component.motData.status = HttpStatusCodes.OK.toString();
component.motData = { status: HttpStatusCodes.OK.toString() } as MotHistoryWithStatus;
expect(component.isSearchFailed()).toEqual(false);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ActivatedRouteMock, AlertControllerMock, PlatformMock, RouterMock } fro
import { Store } from '@ngrx/store';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { TEST_CENTRE_JOURNAL_PAGE, TestFlowPageNames } from '@pages/page-names.constants';
import { MOTAbortedMethod } from '@pages/waiting-room-to-car/components/vehicle-registration/vehicle-registration';
import {
WaitingRoomToCarBikeCategoryChanged,
WaitingRoomToCarBikeCategorySelected,
Expand Down Expand Up @@ -58,6 +59,7 @@ import {
import {
DualControlsToggled,
GearboxCategoryChanged,
MotCallAborted,
SchoolBikeToggled,
SchoolCarToggled,
VehicleRegistrationChanged,
Expand Down Expand Up @@ -382,9 +384,15 @@ describe('WaitingRoomToCarBasePageComponent', () => {
});

describe('abortMOTCall', () => {
it('should emit a value from abortSubject', () => {
it('dispatches MotCallAborted action with the provided method', () => {
const method = MOTAbortedMethod.NAVIGATION;
basePageComponent.abortMOTCall(method);
expect(store$.dispatch).toHaveBeenCalledWith(MotCallAborted(method));
});

it('emits a value from abortSubject', () => {
spyOn(basePageComponent.abortSubject, 'next');
basePageComponent.abortMOTCall();
basePageComponent.abortMOTCall(MOTAbortedMethod.NAVIGATION);
expect(basePageComponent.abortSubject.next).toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,17 @@ export abstract class WaitingRoomToCarBasePageComponent extends PracticeableBase
/**
* Aborts the ongoing MOT call.
*
* This method emits a value from the `abortSubject`,
* which is used to signal the abortion of the ongoing HTTP request.
* This method dispatches the `MotCallAborted` action with the provided method
* and emits a value from the `abortSubject` to signal the abortion of the ongoing HTTP request.
*
* @param {MOTAbortedMethod} method - The method used to abort the MOT call.
*/

abortMOTCall(method: MOTAbortedMethod): void {
this.store$.dispatch(MotCallAborted(method));
this.abortSubject.next();
}

motServiceUnavailable(statusCode: HttpStatusCodes): void {
this.store$.dispatch(MotServiceUnavailable(statusCode));
this.abortSubject.next();
Expand Down

0 comments on commit f785138

Please sign in to comment.