+
+ it("should enable Submit button when ric is selected and json is valid", async () => {
+ const ricSelector: RicSelectorComponent = fixture.debugElement.query(
+ By.directive(RicSelectorComponent)
+ ).componentInstance;
+ const noTypePolicyEditor: NoTypePolicyEditorComponent = fixture.debugElement.query(
+ By.directive(NoTypePolicyEditorComponent)
+ ).componentInstance;
+ let submitButton: MatButtonHarness = await loader.getHarness(
+ MatButtonHarness.with({ selector: "#submitButton" })
+ );
+
+ noTypePolicyEditor.validJson.emit(null);
+ expect(await submitButton.isDisabled()).toBeTruthy();
+
+ ricSelector.selectedRic.emit("ric1");
+ expect(await submitButton.isDisabled()).toBeTruthy();
+
+ noTypePolicyEditor.validJson.emit("{}");
+ expect(await submitButton.isDisabled()).toBeFalsy();
+ });
+
+ it("should generate policy ID when submitting new policy", async () => {
+ const ricSelector: RicSelectorComponent = fixture.debugElement.query(
+ By.directive(RicSelectorComponent)
+ ).componentInstance;
+ const noTypePolicyEditor: NoTypePolicyEditorComponent = fixture.debugElement.query(
+ By.directive(NoTypePolicyEditorComponent)
+ ).componentInstance;
+ let submitButton: MatButtonHarness = await loader.getHarness(
+ MatButtonHarness.with({ selector: "#submitButton" })
+ );
+
+ spyOn(uuid, "v4").and.returnValue("1234567890");
+ ricSelector.selectedRic.emit("ric1");
+ noTypePolicyEditor.validJson.emit("{}");
+ await submitButton.click();
+
+ const policyInstance = {} as CreatePolicyInstance;
+ policyInstance.policy_data = JSON.parse("{}");
+ policyInstance.policy_id = "1234567890";
+ policyInstance.policytype_id = "";
+ policyInstance.ric_id = "ric1";
+ policyInstance.service_id = "controlpanel";
+ expect(policyServiceSpy.putPolicy).toHaveBeenCalledWith(policyInstance);
+ });