Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
olusegz07 committed Jan 8, 2025
1 parent f5ebfd0 commit 557d2bd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,20 @@ describe('UnLinkCasesComponent', () => {

it('should getLinkedCases populate linked cases', () => {
component.getLinkedCases();
expect(component.caseId).toEqual('1682374819203471');
expect(component.linkedCases.length).toEqual(2);
expect(component.linkedCases[0].caseReference).toEqual('1682374819203471');
expect(component.linkedCases[1].caseReference).toEqual('1682897456391875');
});

it('should fetch linked cases from case service when service is empty', () => {
linkedCasesService.linkedCases = [];
component.getLinkedCases();
expect(casesService.getCaseViewV2).toHaveBeenCalledWith('1682374819203471');
expect(component.linkedCases.length).toBe(3);
expect(component.linkedCases[0].caseReference).toBe('1652112127295261');
});

it('should update the unlink property of linked case with correct value', () => {
component.linkedCases = linkedCases;
const caseSelected1 = {
Expand All @@ -193,4 +202,11 @@ describe('UnLinkCasesComponent', () => {
expect(component.linkedCases[0].unlink).toBeUndefined();
expect(component.linkedCases[1].unlink).toBe(true);
});

it('should fetch and update linked case information', () => {
component.getAllLinkedCaseInformation();

expect(linkedCasesService.linkedCases).toEqual(component.linkedCases);
expect(component.isServerError).toBeFalsy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
import { of, throwError } from 'rxjs';
import { AbstractAppConfig } from '../../../../app.config';
import { CaseEditDataService } from '../../../commons/case-edit-data/case-edit-data.service';
import { CaseEventData } from '../../../domain/case-event-data.model';
Expand All @@ -30,6 +30,7 @@ import { WriteLinkedCasesFieldComponent } from './write-linked-cases-field.compo
import createSpyObj = jasmine.createSpyObj;
import { ServiceOrg } from '../../../domain/case-view/service-org-response.model';
import { ValidPageListCaseFieldsService } from '../../case-editor/services/valid-page-list-caseFields.service';
import { By } from '@angular/platform-browser';

describe('WriteLinkedCasesFieldComponent', () => {
let component: WriteLinkedCasesFieldComponent;
Expand Down Expand Up @@ -447,6 +448,12 @@ describe('WriteLinkedCasesFieldComponent', () => {
expect(component.getNextPage(linkedCasesState2)).toEqual(LinkedCasesPages.CHECK_YOUR_ANSWERS);
});

it('should fetch caseView, filter tabs, and initialize linked cases correctly', () => {
component.getLinkedCases();

expect(component.linkedCasesPage).toBe(LinkedCasesPages.BEFORE_YOU_START);
});

function createCaseField(id: string, value: any, displayContext = 'READONLY'): CaseField {
const cf = new CaseField();
cf.id = id;
Expand Down

0 comments on commit 557d2bd

Please sign in to comment.