Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
RDM-3023 Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewf committed Oct 10, 2018
1 parent 7f89980 commit 1e2bde3
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 145 deletions.
23 changes: 14 additions & 9 deletions src/app/shared/header/case-header.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,25 @@ describe('CaseHeaderComponent', () => {
LabelSubstitutionService,
]
})
.compileComponents();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(CaseHeaderComponent);
component = fixture.componentInstance;
component.caseDetails = CASE_DETAILS;

fixture = TestBed.createComponent(CaseHeaderComponent);
component = fixture.componentInstance;
component.caseDetails = CASE_DETAILS;

de = fixture.debugElement;
fixture.detectChanges();
de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should render a header with case reference when title display is empty', () => {
let header = de.query($HEADING);
expect(header).toBeTruthy();
expect(text(header)).toEqual('#1234-5678-9012-3456');
fixture
.whenStable()
.then(() => {
expect(header).toBeTruthy();
expect(text(header)).toEqual('#1234-5678-9012-3456');
});
});

it('should render a header with markdown element when title display is not empty', () => {
Expand Down
44 changes: 25 additions & 19 deletions src/app/shared/search/filters/search-filters.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,31 +163,37 @@ describe('SearchFiltersComponent', () => {
{ provide: JurisdictionService, useValue: jurisdictionService },
]
})
.compileComponents();

fixture = TestBed.createComponent(SearchFiltersComponent);
component = fixture.componentInstance;

component.formGroup = TEST_FORM_GROUP;
component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.onApply.subscribe(searchHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(SearchFiltersComponent);
component = fixture.componentInstance;

component.formGroup = TEST_FORM_GROUP;
component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.onApply.subscribe(searchHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should select the jurisdiction if there is only one jurisdiction', () => {
it('should select the jurisdiction if there is only one jurisdiction', async(() => {
resetCaseTypes(JURISDICTION_1, []);
mockSearchService.getSearchInputs.and.returnValue(createObservableFrom(TEST_SEARCH_INPUTS));
component.jurisdictions = [JURISDICTION_1];
fixture.detectChanges();
component.ngOnInit();
fixture.detectChanges();
expect(component.selected.jurisdiction).toBe(JURISDICTION_1);
expect(component.selected.caseType).toBe(null);
});

fixture
.whenStable()
.then(() => {
expect(component.selected.jurisdiction).toBe(JURISDICTION_1);
expect(component.selected.caseType).toBe(null);
});
}));

it('should select the first caseType ', () => {
resetCaseTypes(JURISDICTION_1, [CASE_TYPE_1, CASE_TYPE_2]);
Expand Down
244 changes: 127 additions & 117 deletions src/app/workbasket/filters/workbasket-filters.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,26 @@ describe('WorkbasketFiltersComponent', () => {
{ provide: AlertService, useValue: alertService },
]
})
.compileComponents();

fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: DEFAULT_CASE_TYPE.id,
state_id: DEFAULT_CASE_STATE.id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: DEFAULT_CASE_TYPE.id,
state_id: DEFAULT_CASE_STATE.id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should have an Apply button disabled when case type is set but state is not set', async(() => {
Expand Down Expand Up @@ -387,12 +388,16 @@ describe('WorkbasketFiltersComponent', () => {
fixture.detectChanges();

let button = de.query($APPLY_BUTTON);
expect(button.nativeElement.disabled).toBeTruthy();
fixture
.whenStable()
.then(() => {

component.selected.jurisdiction = JURISDICTION_1;
component.onJurisdictionIdChange();
expect(component.workbasketInputsReady).toBeFalsy();
expect(button.nativeElement.disabled).toBeTruthy();

component.selected.jurisdiction = JURISDICTION_1;
component.onJurisdictionIdChange();
expect(component.workbasketInputsReady).toBeFalsy();
});
}));

it('should have form group details added when apply button is clicked ', async(() => {
Expand Down Expand Up @@ -524,24 +529,25 @@ describe('WorkbasketFiltersComponent', () => {
{ provide: AlertService, useValue: alertService }
]
})
.compileComponents();

fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;
component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: CASE_TYPES_2[1].id,
state_id: CASE_TYPES_2[1].states[1].id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;
component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: CASE_TYPES_2[1].id,
state_id: CASE_TYPES_2[1].states[1].id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should populate case types drop down with CRUD filtered case types and sort states', async(() => {
Expand Down Expand Up @@ -616,25 +622,26 @@ describe('WorkbasketFiltersComponent', () => {
{ provide: AlertService, useValue: alertService }
]
})
.compileComponents();

fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: CRUD_FILTERED_CASE_TYPES[0].id,
state_id: CRUD_FILTERED_CASE_TYPES[0].states[0].id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: CRUD_FILTERED_CASE_TYPES[0].id,
state_id: CRUD_FILTERED_CASE_TYPES[0].states[0].id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should disable case type dropdown if default is filtered out due to CRUD and no other case types', async(() => {
Expand Down Expand Up @@ -685,25 +692,26 @@ describe('WorkbasketFiltersComponent', () => {
{ provide: AlertService, useValue: alertService }
]
})
.compileComponents();

fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: CRUD_FILTERED_CASE_TYPES[1].id,
state_id: CRUD_FILTERED_CASE_TYPES[0].states[0].id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: CRUD_FILTERED_CASE_TYPES[1].id,
state_id: CRUD_FILTERED_CASE_TYPES[0].states[0].id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should disable states dropdown if default is filtered out due to CRUD and no other states', async(() => {
Expand Down Expand Up @@ -761,25 +769,26 @@ describe('WorkbasketFiltersComponent', () => {
{ provide: AlertService, useValue: alertService },
]
})
.compileComponents();

fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: DEFAULT_CASE_TYPE.id,
state_id: DEFAULT_CASE_STATE.id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: DEFAULT_CASE_TYPE.id,
state_id: DEFAULT_CASE_STATE.id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should initially select jurisdiction based on query parameter', () => {
Expand Down Expand Up @@ -851,25 +860,26 @@ describe('WorkbasketFiltersComponent', () => {
{ provide: AlertService, useValue: alertService }
]
})
.compileComponents();

fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: DEFAULT_CASE_TYPE.id,
state_id: DEFAULT_CASE_STATE.id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
.compileComponents()
.then(() => {
fixture = TestBed.createComponent(WorkbasketFiltersComponent);
component = fixture.componentInstance;

component.jurisdictions = [
JURISDICTION_1,
JURISDICTION_2
];
component.formGroup = TEST_FORM_GROUP;
component.defaults = {
jurisdiction_id: JURISDICTION_2.id,
case_type_id: DEFAULT_CASE_TYPE.id,
state_id: DEFAULT_CASE_STATE.id
};
component.onApply.subscribe(workbasketHandler.applyFilters);

de = fixture.debugElement;
fixture.detectChanges();
});
}));

it('should initially NOT select anything if jurisdiction is invalid and no case types', () => {
Expand Down

0 comments on commit 1e2bde3

Please sign in to comment.