+ describe("normally functioning", () => {
+ beforeEach(() => {
+ const policyTypes = { policytype_ids: ["type1", "type2"] } as PolicyTypes;
+ policyServiceSpy.getPolicyTypes.and.returnValue(of(policyTypes));
+
+ 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);
+ })