Skip to content

Commit

Permalink
Replace interface with class
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-scott committed Dec 17, 2024
1 parent 77a1d3b commit d13efba
Show file tree
Hide file tree
Showing 38 changed files with 320 additions and 326 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { InterpreterFormComponent } from '../interpreter-form/interpreter-form.c
import { MockComponent } from 'ng-mocks';
import { InterpreterSelectedDto } from '../interpreter-form/interpreter-selected.model';
import { FeatureFlagDirective } from 'src/app/src/app/shared/feature-flag.directive';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';

let component: AddParticipantComponent;
let fixture: ComponentFixture<AddParticipantComponent>;
Expand Down Expand Up @@ -179,7 +179,7 @@ participants.push(p3);
participants.push(p4);

function initHearingRequest(): VHBooking {
const newHearing = createVHBooking();
const newHearing = new VHBooking();
newHearing.hearing_venue_id = -1;
newHearing.scheduled_duration = 0;
newHearing.participants = participants;
Expand All @@ -189,7 +189,7 @@ function initHearingRequest(): VHBooking {
}

function initExistHearingRequest(): VHBooking {
const newHearing = createVHBooking();
const newHearing = new VHBooking();
newHearing.hearing_id = '12345';
newHearing.hearing_venue_id = 1;
newHearing.scheduled_duration = 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { LinkedParticipantModel, LinkedParticipantType } from 'src/app/common/mo
import { takeUntil } from 'rxjs/operators';
import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service';
import { InterpreterSelectedDto } from '../interpreter-form/interpreter-selected.model';
import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters';

@Component({
selector: 'app-add-participant',
Expand Down Expand Up @@ -324,7 +325,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme

this.hearing.participants.push(newParticipant);
this.hearing.participants = [...this.hearing.participants];
this.hearing = { ...this.hearing };
this.hearing = cloneWithGetters(this.hearing);

this.populateInterpretedForList();
this.videoHearingService.updateHearingRequest(this.hearing);
Expand Down Expand Up @@ -392,7 +393,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme
}
});
this.hearing.participants = [...this.hearing.participants];
this.hearing = { ...this.hearing };
this.hearing = cloneWithGetters(this.hearing);
this.clearForm();
this.participantDetails = null;
this.form.markAsPristine();
Expand Down Expand Up @@ -442,7 +443,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme
}
this.participantService.removeParticipant(this.hearing, this.selectedParticipantEmail);
this.removeLinkedParticipant(this.selectedParticipantEmail);
this.hearing = { ...this.hearing };
this.hearing = cloneWithGetters(this.hearing);
this.videoHearingService.updateHearingRequest(this.hearing);
this.videoHearingService.setBookingHasChanged();
}
Expand Down Expand Up @@ -759,7 +760,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme
}
this.participantService.removeParticipant(this.hearing, this.selectedParticipantEmail);
this.removeLinkedParticipant(this.selectedParticipantEmail);
this.hearing = { ...this.hearing };
this.hearing = cloneWithGetters(this.hearing);
this.videoHearingService.updateHearingRequest(this.hearing);
this.videoHearingService.setBookingHasChanged();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { PageUrls } from 'src/app/shared/page-url.constants';
import { SearchEmailComponent } from '../search-email/search-email.component';
import { MockComponent } from 'ng-mocks';
import { Constants } from 'src/app/common/constants';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';

function initHearingRequest(): VHBooking {
const participants: ParticipantModel[] = [];
Expand Down Expand Up @@ -52,7 +52,7 @@ function initHearingRequest(): VHBooking {
participants.push(p1);
participants.push(p2);

const newHearing = createVHBooking();
const newHearing = new VHBooking();
newHearing.participants = participants;

newHearing.hearing_venue_id = -1;
Expand Down Expand Up @@ -511,7 +511,7 @@ describe('AssignJudgeComponent', () => {

describe('updateJudge', () => {
beforeEach(() => {
component.hearing = createVHBooking();
component.hearing = new VHBooking();
component.canNavigate = null;

component.judgeDisplayNameFld.setValue(initialJudgeDisplayNameFld);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { PipeStringifierService } from '../../services/pipe-stringifier.service'
import { EmailValidationService } from 'src/app/booking/services/email-validation.service';
import { ConfigService } from '../../services/config.service';
import { map } from 'rxjs/operators';
import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters';
@Component({
selector: 'app-assign-judge',
templateUrl: './assign-judge.component.html',
Expand Down Expand Up @@ -131,7 +132,7 @@ export class AssignJudgeComponent extends BookingBaseComponent implements OnInit
this.removeJudge();
}

this.hearing = { ...this.hearing };
this.hearing = cloneWithGetters(this.hearing);
this.setTextFieldValues();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import { createMultiDayHearing } from 'src/app/testing/helpers/hearing.helpers';
import { VideoSupplier } from 'src/app/services/clients/api-client';
import { ServiceIds } from '../models/supplier-override';
import { ReferenceDataService } from 'src/app/services/reference-data.service';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';

function initHearingRequest(): VHBooking {
const newHearing = createVHBooking();
const newHearing = new VHBooking();
newHearing.hearing_venue_id = -1;
newHearing.scheduled_duration = 0;
return newHearing;
}

function initExistingHearingRequest(): VHBooking {
const existingRequest = createVHBooking();
const existingRequest = new VHBooking();
existingRequest.hearing_venue_id = 1;
existingRequest.case_type = 'Generic';

Expand Down Expand Up @@ -442,7 +442,7 @@ describe('CreateHearingComponent with existing request in session', () => {
hearing.isMultiDayEdit = false;
videoHearingsServiceSpy.getCurrentRequest.and.returnValue(hearing);
});
it('should disable editing of case name when multi-day hearing enhancements are enabled', fakeAsync(() => {
fit('should disable editing of case name when multi-day hearing enhancements are enabled', fakeAsync(() => {
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(true));
component.ngOnInit();
tick();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { VideoEndpointListComponent } from './video-endpoint-list/video-endpoint
import { VideoEndpointItemComponent } from './video-endpoint-item/video-endpoint-item.component';
import { BreadcrumbStubComponent } from 'src/app/testing/stubs/breadcrumb-stub';
import { FeatureFlagDirective } from 'src/app/src/app/shared/feature-flag.directive';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';

function initHearingRequest(): VHBooking {
const newHearing = createVHBooking();
const newHearing = new VHBooking();
newHearing.hearing_venue_id = -1;
newHearing.scheduled_duration = 0;
newHearing.participants = [
Expand Down Expand Up @@ -185,8 +185,8 @@ describe('EndpointsComponent', () => {

describe('when booking is multi day', () => {
beforeEach(() => {
const booking = createVHBooking();
booking.isMultiDay = true;
const booking = new VHBooking();
booking.groupId = '123';
videoHearingsServiceSpy.getCurrentRequest.and.returnValue(booking);
});
it('should navigate to the summary page when next clicked and multi day booking enhancements are enabled', () => {
Expand All @@ -204,12 +204,12 @@ describe('EndpointsComponent', () => {
});
describe('when booking is not multi day', () => {
beforeEach(() => {
const booking = createVHBooking();
booking.isMultiDay = false;
const booking = new VHBooking();
booking.groupId = '123';
videoHearingsServiceSpy.getCurrentRequest.and.returnValue(booking);
});

it('should navigate to the other information page when next clicked and multi day booking enhancements are enabled', () => {
fit('should navigate to the other information page when next clicked and multi day booking enhancements are enabled', () => {
featureServiceSpy.getFlag.withArgs(FeatureFlags.multiDayBookingEnhancements).and.returnValue(of(true));
component.ngOnInit();
component.videoEndpoints = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkl
import { By } from '@angular/platform-browser';
import { createMultiDayHearing } from 'src/app/testing/helpers/hearing.helpers';
import { EditHearingDatesComponent } from './edit-hearing-dates/edit-hearing-dates.component';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';
import { cloneWithGetters } from 'src/app/common/helpers/clone-with-getters';

const newHearing = createVHBooking();
const newHearing = new VHBooking();

function initExistingHearingRequest(): VHBooking {
const today = new Date();
today.setHours(10, 30);

const existingRequest = createVHBooking();
const existingRequest = new VHBooking();
existingRequest.hearing_venue_id = 1;
existingRequest.scheduled_date_time = today;
existingRequest.scheduled_duration = 80;
Expand Down Expand Up @@ -528,7 +529,7 @@ describe('HearingScheduleComponent returning to page', () => {
new HearingVenueResponse({ id: 1, name: '[email protected]', code: '123' }),
new HearingVenueResponse({ id: 2, name: '[email protected]', code: '456' })
];
component.hearing = createVHBooking();
component.hearing = new VHBooking();
component.hearing.hearing_venue_id = 2;
component.hearing.court_code = '456';
component.hearing.court_name = '[email protected]';
Expand All @@ -541,7 +542,7 @@ describe('HearingScheduleComponent returning to page', () => {
const courts = MockValues.Courts.filter(x => x.id !== -1);
const selectedCourt = courts[0];
referenceDataServiceServiceSpy.getCourts.and.returnValue(of(courts));
const existingHearingRequest = { ...existingRequest };
const existingHearingRequest = cloneWithGetters(existingRequest);
existingHearingRequest.hearing_id = '123455555900';
existingHearingRequest.court_name = selectedCourt.name;
videoHearingsServiceSpy.getCurrentRequest.and.returnValue(existingHearingRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BookingService } from 'src/app/services/booking.service';
import { Logger } from 'src/app/services/logger';
import { AddJudicialOfficeHoldersComponent } from './add-judicial-office-holders.component';
import { Router } from '@angular/router';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';
import { ParticipantListComponent } from '../../participant';
import { ParticipantsListStubComponent } from 'src/app/testing/stubs/participant-list-stub';
import { BreadcrumbComponent } from '../../breadcrumb/breadcrumb.component';
Expand Down Expand Up @@ -34,7 +34,7 @@ describe('AddJudicialOfficeHoldersComponent', () => {
beforeEach(async () => {
launchDarklyServiceSpy = jasmine.createSpyObj<LaunchDarklyService>('LaunchDarklyService', ['getFlag']);
launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.interpreterEnhancements).and.returnValue(of(false));
hearing = createVHBooking();
hearing = new VHBooking();
hearing.judiciaryParticipants = [];
videoHearingsServiceSpy = jasmine.createSpyObj('VideoHearingsService', [
'getCurrentRequest',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ export class JudicialMemberDto {

return dto;
}

static judgeWithDisplayName(displayName: string): JudicialMemberDto {
const dto = new JudicialMemberDto(null, null, null, null, null, null, false);
dto.displayName = displayName;
dto.roleCode = 'Judge';

return dto
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { BreadcrumbComponent } from '../breadcrumb/breadcrumb.component';
import { OtherInformationComponent } from './other-information.component';
import { ParticipantModel } from '../../common/model/participant.model';
import { CaseModel } from 'src/app/common/model/case.model';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';
import { LaunchDarklyService } from 'src/app/services/launch-darkly.service';
import { BreadcrumbStubComponent } from 'src/app/testing/stubs/breadcrumb-stub';

Expand All @@ -21,7 +21,7 @@ function initHearingRequest(): VHBooking {

const cases: CaseModel[] = [];

const newHearing = createVHBooking();
const newHearing = new VHBooking();
newHearing.case = cases[0];
newHearing.participants = participants;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Constants } from 'src/app/common/constants';
import { ParticipantModel } from 'src/app/common/model/participant.model';
import { PageUrls } from 'src/app/shared/page-url.constants';
import { VideoSupplier } from 'src/app/services/clients/api-client';
import { VHBooking } from 'src/app/common/model/vh-booking';

const router = {
navigate: jasmine.createSpy('navigate'),
Expand Down Expand Up @@ -51,11 +52,11 @@ describe('ParticipantItemComponent', () => {
fixture = TestBed.createComponent(ParticipantItemComponent);
debugElement = fixture.debugElement;
component = debugElement.componentInstance;
component.hearing = {
updated_date: new Date(),
other_information: '|JudgeEmail|[email protected]|JudgePhone|123456789',
supplier: VideoSupplier.Kinly
};
const hearing = new VHBooking();
hearing.updated_date = new Date(),
hearing.other_information = '|JudgeEmail|[email protected]|JudgePhone|123456789',
hearing.supplier = VideoSupplier.Kinly;
component.hearing = hearing;

fixture.detectChanges();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { FeatureFlags, LaunchDarklyService } from '../../../services/launch-dark
import { of } from 'rxjs';
import { InterpreterSelectedDto } from '../../interpreter-form/interpreter-selected.model';
import { VideoSupplier } from 'src/app/services/clients/api-client';
import { VHBooking } from 'src/app/common/model/vh-booking';

const loggerSpy = jasmine.createSpyObj<Logger>('Logger', ['error', 'debug', 'warn']);
const router = {
Expand Down Expand Up @@ -63,7 +64,10 @@ describe('ParticipantListComponent', () => {
fixture = TestBed.createComponent(ParticipantListComponent);
debugElement = fixture.debugElement;
component = debugElement.componentInstance;
component.hearing = { updated_date: new Date(), supplier: VideoSupplier.Kinly };
const hearing = new VHBooking();
hearing.updated_date = new Date();
hearing.supplier = VideoSupplier.Kinly;
component.hearing = hearing;
fixture.detectChanges();
});

Expand Down Expand Up @@ -335,7 +339,10 @@ describe('ParticipantListComponent-SortParticipants', () => {
fixture = TestBed.createComponent(ParticipantListComponent);
debugElement = fixture.debugElement;
component = debugElement.componentInstance;
component.hearing = { updated_date: new Date(), supplier: VideoSupplier.Kinly };
const hearing = new VHBooking();
hearing.updated_date = new Date();
hearing.supplier = VideoSupplier.Kinly;
component.hearing = hearing;
fixture.detectChanges();
});
it('should produce a sorted list with no duplicates', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ScreeningFormComponent as ScreeningFormComponent } from './screening-fo
import { Logger } from 'src/app/services/logger';
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
import { EndpointModel } from 'src/app/common/model/endpoint.model';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';
import { ParticipantModel } from 'src/app/common/model/participant.model';

describe('ScreeningFormComponent', () => {
Expand All @@ -14,7 +14,7 @@ describe('ScreeningFormComponent', () => {
let hearing: VHBooking;

beforeEach(async () => {
hearing = createVHBooking();
hearing = new VHBooking();
const participant1 = new ParticipantModel();
participant1.id = '1';
participant1.email = 'email1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ScreeningListItemComponent } from './screening-list-item.component';
import { EndpointModel } from 'src/app/common/model/endpoint.model';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';
import { ParticipantModel } from 'src/app/common/model/participant.model';
import { SimpleChange, SimpleChanges } from '@angular/core';

Expand All @@ -12,7 +12,7 @@ describe('ScreeningListItemComponent', () => {
let hearing: VHBooking;

beforeEach(async () => {
hearing = createVHBooking();
hearing = new VHBooking();
const participantWithoutScreening = new ParticipantModel();
participantWithoutScreening.id = '1';
participantWithoutScreening.display_name = 'Participant No Screening';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ScreeningListComponent } from './screening-list.component';
import { createVHBooking, VHBooking } from 'src/app/common/model/vh-booking';
import { VHBooking } from 'src/app/common/model/vh-booking';
import { ParticipantModel } from 'src/app/common/model/participant.model';
import { EndpointModel } from 'src/app/common/model/endpoint.model';
import { SimpleChange, SimpleChanges } from '@angular/core';
Expand All @@ -12,7 +12,7 @@ describe('ScreeningListComponent', () => {
let hearing: VHBooking;

beforeEach(async () => {
hearing = createVHBooking();
hearing = new VHBooking();
const participantWithoutScreening = new ParticipantModel();
participantWithoutScreening.id = '1';
participantWithoutScreening.display_name = 'Participant No Screening';
Expand Down
Loading

0 comments on commit d13efba

Please sign in to comment.