+ compileAndGetComponents();
+ });
+
+ it("should create", () => {
+ expect(hostComponent).toBeTruthy();
+ });
+
+ it("should contain two PolicyType components instantiated with the correct type", () => {
+ const typeComponents: PolicyTypeComponent[] = hostFixture.debugElement
+ .queryAll(By.directive(PolicyTypeComponent))
+ .map((component) => component.componentInstance);
+
+ expect(typeComponents.length).toEqual(2);
+ expect(typeComponents[0].policyTypeId).toEqual("type1");
+ expect(typeComponents[1].policyTypeId).toEqual("type2");
+ });
+
+ it("should call the refresh button when clicking on it", async () => {
+ let refreshButton: MatButtonHarness = await loader.getHarness(
+ MatButtonHarness.with({ selector: "#refreshButton" })
+ );
+ spyOn(hostComponent, "refreshTables");
+ await refreshButton.click();
+ expect(hostComponent.refreshTables).toHaveBeenCalled();
+ })
+
+ it("should close instance tables when clicking on refresh button", async () => {
+ let refreshButton: MatButtonHarness = await loader.getHarness(
+ MatButtonHarness.with({ selector: "#refreshButton" })
+ );
+ const policyTypeComponent: PolicyTypeComponent = hostFixture.debugElement.query(
+ By.directive(PolicyTypeComponent)
+ ).componentInstance;
+ let booleanTrigger = policyTypeComponent.minimiseTrigger
+ await refreshButton.click();
+ expect(policyTypeComponent.minimiseTrigger).not.toEqual(booleanTrigger);
+ })
+
+ it("should render the types sorted when clicking on refresh button", async () => {
+ const typeComponents: PolicyTypeComponent[] = hostFixture.debugElement
+ .queryAll(By.directive(PolicyTypeComponent))
+ .map((component) => component.componentInstance);
+
+ for(var i= 0; i < typeComponents.length-1; i++){
+ expect(typeComponents[i].policyTypeId<typeComponents[i+1].policyTypeId).toBeTruthy();
+ }
+ })
+ })
+
+ describe("no types", () => {
+ beforeEach(() => {
+ policyServiceSpy.getPolicyTypes.and.returnValue(
+ of({
+ policytype_ids: [],
+ } as PolicyTypes)
+ );