-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shaed Parkar
committed
Nov 7, 2023
1 parent
5ce9d4b
commit 83f4752
Showing
7 changed files
with
183 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { SearchForJudicialMemberComponent } from '../search-for-judicial-member/ | |
import { JudicialService } from '../../services/judicial.service'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { PageUrls } from 'src/app/shared/page-url.constants'; | ||
import { JudicialMemberDto } from '../models/add-judicial-member.model'; | ||
|
||
describe('AddJudicialOfficeHoldersComponent', () => { | ||
let component: AddJudicialOfficeHoldersComponent; | ||
|
@@ -111,4 +112,58 @@ describe('AddJudicialOfficeHoldersComponent', () => { | |
expect(routerSpy.navigate).toHaveBeenCalledWith([PageUrls.AddParticipants]); | ||
}); | ||
}); | ||
|
||
describe('prepoplateFormForEdit', () => { | ||
it('should set participantToEdit and editingJudge to true when participant role is Judge', () => { | ||
// Arrange | ||
const participantEmail = '[email protected]'; | ||
const judicialMember = new JudicialMemberDto('Test', 'User', 'Test User', participantEmail, '1234567890', '1234'); | ||
judicialMember.roleCode = 'Judge'; | ||
judicialMember.displayName = 'Test User display name'; | ||
component.hearing.judiciaryParticipants = [judicialMember]; | ||
|
||
// Act | ||
component.prepoplateFormForEdit(participantEmail); | ||
|
||
// Assert | ||
expect(component.participantToEdit).toEqual(judicialMember); | ||
expect(component.editingJudge).toBeTrue(); | ||
expect(component.editingPanelMember).toBeFalse(); | ||
expect(component.showAddPanelMember).toBeFalse(); | ||
}); | ||
|
||
it('should set participantToEdit, editingPanelMember and showAddPanelMember to true when participant role is not Judge', () => { | ||
// Arrange | ||
const participantEmail = '[email protected]'; | ||
const panelMemberParticipant = new JudicialMemberDto('Test', 'User', 'Test User', participantEmail, '1234567890', '1234'); | ||
panelMemberParticipant.roleCode = 'PanelMember'; | ||
component.hearing.judiciaryParticipants = [panelMemberParticipant]; | ||
|
||
// Act | ||
component.prepoplateFormForEdit(participantEmail); | ||
|
||
// Assert | ||
expect(component.participantToEdit).toEqual(panelMemberParticipant); | ||
expect(component.editingJudge).toBeFalse(); | ||
expect(component.editingPanelMember).toBeTrue(); | ||
expect(component.showAddPanelMember).toBeTrue(); | ||
}); | ||
|
||
it('should log warning when participant is not found', () => { | ||
// Arrange | ||
const participantEmail = '[email protected]'; | ||
component.hearing.judiciaryParticipants = []; | ||
|
||
// Act | ||
component.prepoplateFormForEdit(participantEmail); | ||
|
||
// Assert | ||
expect(loggerSpy.warn.calls.mostRecent().args[0].includes('Unable to find participant to edit.')).toBeTrue(); | ||
expect(loggerSpy.warn.calls.mostRecent().args[1]).toBe(participantEmail); | ||
expect(component.participantToEdit).toBeNull(); | ||
expect(component.editingJudge).toBeFalse(); | ||
expect(component.editingPanelMember).toBeFalse(); | ||
expect(component.showAddPanelMember).toBeFalse(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ import { Logger } from 'src/app/services/logger'; | |
import { ParticipantItemComponent } from './participant-item.component'; | ||
import { VideoHearingsService } from 'src/app/services/video-hearings.service'; | ||
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'; | ||
|
||
const router = { | ||
navigate: jasmine.createSpy('navigate'), | ||
|
@@ -70,11 +72,42 @@ describe('ParticipantItemComponent', () => { | |
it('should edit participant details', () => { | ||
component.isSummaryPage = true; | ||
component.participant = { representee: 'rep', is_judge: false, is_exist_person: false, isJudiciaryMember: false }; | ||
component.editParticipant({ email: '[email protected]', is_exist_person: false, is_judge: false, isJudiciaryMember: false }); | ||
const participant: ParticipantModel = { | ||
email: '[email protected]', | ||
is_exist_person: false, | ||
is_judge: false, | ||
isJudiciaryMember: false | ||
}; | ||
component.editParticipant(participant); | ||
fixture.detectChanges(); | ||
expect(bookingServiceSpy.setEditMode).toHaveBeenCalled(); | ||
expect(bookingServiceSpy.setParticipantEmail).toHaveBeenCalledWith(participant.email); | ||
expect(router.navigate).toHaveBeenCalledWith([PageUrls.AddParticipants]); | ||
}); | ||
|
||
it('should edit judicial office holder details', () => { | ||
component.isSummaryPage = true; | ||
component.participant = { representee: 'rep', is_judge: true, is_exist_person: false, isJudiciaryMember: true }; | ||
const participant: ParticipantModel = { email: '[email protected]', is_exist_person: false, is_judge: true, isJudiciaryMember: true }; | ||
component.editParticipant(participant); | ||
fixture.detectChanges(); | ||
expect(bookingServiceSpy.setEditMode).toHaveBeenCalled(); | ||
expect(bookingServiceSpy.setEditMode).toHaveBeenCalledWith(); | ||
expect(router.navigate).toHaveBeenCalled(); | ||
expect(bookingServiceSpy.setParticipantEmail).toHaveBeenCalledWith(participant.email); | ||
expect(router.navigate).toHaveBeenCalledWith([PageUrls.AddJudicialOfficeHolders]); | ||
}); | ||
|
||
it('should emit edit event for non-summary page', () => { | ||
component.isSummaryPage = false; | ||
const participant: ParticipantModel = { | ||
email: '[email protected]', | ||
is_exist_person: false, | ||
is_judge: false, | ||
isJudiciaryMember: false | ||
}; | ||
spyOn(component.edit, 'emit'); | ||
component.editParticipant(participant); | ||
fixture.detectChanges(); | ||
expect(component.edit.emit).toHaveBeenCalledWith(participant); | ||
}); | ||
|
||
it('should return true if participant has a representative', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { BookingParticipantListComponent } from './booking-participant-list.comp | |
import { HearingRoles } from '../../common/model/hearing-roles.model'; | ||
import { LinkedParticipant } from '../../services/clients/api-client'; | ||
import { ParticipantDetailsComponent } from '../participant-details/participant-details.component'; | ||
import { JudiciaryParticipantDetailsModel } from 'src/app/common/model/judiciary-participant-details.model'; | ||
|
||
describe('BookingParticipantListComponent', () => { | ||
let component: BookingParticipantListComponent; | ||
|
@@ -209,4 +210,48 @@ describe('BookingParticipantListComponent', () => { | |
} | ||
done(); | ||
}); | ||
|
||
it('should sort judiciary participants and members', () => { | ||
const jp1 = new JudiciaryParticipantDetailsModel( | ||
'Mrs', | ||
'Alan', | ||
'Brake', | ||
'Judge', | ||
'[email protected]', | ||
'[email protected]', | ||
'Judge', | ||
'Judge', | ||
'Alan Brake' | ||
); | ||
const jp2 = new JudiciaryParticipantDetailsModel( | ||
'Mr', | ||
'John', | ||
'Doe', | ||
'Winger', | ||
'[email protected]', | ||
'[email protected]', | ||
'Winger', | ||
'PanelMember', | ||
'John Doe' | ||
); | ||
const jp3 = new JudiciaryParticipantDetailsModel( | ||
'Ms', | ||
'Jane', | ||
'Doe', | ||
'Panel Member', | ||
'[email protected]', | ||
'[email protected]', | ||
'Panel Member', | ||
'PanelMember', | ||
'Jane Doe' | ||
); | ||
|
||
const judiciaryParticipants = [jp1, jp2, jp3]; | ||
component.judiciaryParticipants = judiciaryParticipants; | ||
|
||
expect(component.sortedJudiciaryMembers.length).toEqual(3); | ||
expect(component.sortedJudiciaryMembers[0]).toEqual(jp1); | ||
expect(component.sortedJudiciaryMembers[1]).toEqual(jp3); | ||
expect(component.sortedJudiciaryMembers[2]).toEqual(jp2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -707,4 +707,43 @@ describe('Video hearing service', () => { | |
expect(service['modelHearing'].judiciaryParticipants[0]).toEqual(judicialMember2); | ||
}); | ||
}); | ||
|
||
fdescribe('removeJudiciaryParticipant', () => { | ||
it('should remove judiciary participant from modelHearing', () => { | ||
// Arrange | ||
const participantEmail = '[email protected]'; | ||
const judicialMember = new JudicialMemberDto('Test', 'User', 'Test User', participantEmail, '1234567890', '1234'); | ||
service['modelHearing'].judiciaryParticipants = [judicialMember]; | ||
|
||
// Act | ||
service.removeJudiciaryParticipant(participantEmail); | ||
|
||
// Assert | ||
expect(service['modelHearing'].judiciaryParticipants).not.toContain(judicialMember); | ||
}); | ||
|
||
it('should not remove judiciary participant if email does not match', () => { | ||
// Arrange | ||
const participantEmail = '[email protected]'; | ||
const judicialMember = new JudicialMemberDto('Test', 'User', 'Test User', participantEmail, '1234567890', '1234'); | ||
service['modelHearing'].judiciaryParticipants = [judicialMember]; | ||
|
||
// Act | ||
service.removeJudiciaryParticipant('[email protected]'); | ||
|
||
// Assert | ||
expect(service['modelHearing'].judiciaryParticipants).toContain(judicialMember); | ||
}); | ||
|
||
it('should not remove judiciary participant if modelHearing is undefined', () => { | ||
// Arrange | ||
service['modelHearing'] = undefined; | ||
|
||
// Act | ||
service.removeJudiciaryParticipant('[email protected]'); | ||
|
||
// Assert | ||
expect(service['modelHearing']).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters