X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fpolicy%2Fno-type-policy-editor%2Fno-type-policy-editor.component.spec.ts;h=7c552bc1ddd0e9a86bfdb1eb3eef2003fa96f521;hb=4af3bc930eb59eb9457db01b3b6ccf6b7376aaad;hp=33170dba47165fe46cf231e0fde52299d332bfab;hpb=04b4e622e4435be82fa05ceefa37e8e4ca419e84;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/policy/no-type-policy-editor/no-type-policy-editor.component.spec.ts b/webapp-frontend/src/app/policy/no-type-policy-editor/no-type-policy-editor.component.spec.ts index 33170db..7c552bc 100644 --- a/webapp-frontend/src/app/policy/no-type-policy-editor/no-type-policy-editor.component.spec.ts +++ b/webapp-frontend/src/app/policy/no-type-policy-editor/no-type-policy-editor.component.spec.ts @@ -89,43 +89,40 @@ describe("NoTypePolicyEditorComponent", () => { expect(await formatButton.isDisabled()).toBeTruthy(); }); - it("should format unformatted json", async () => { - const textArea = component.noTypePolicyEditorComponent.instanceForm.get( - "policyJsonTextArea" + it("should send valid json", async () => { + const textAreaHarness: MatInputHarness = await loader.getHarness( + MatInputHarness.with({ selector: "#policyJsonTextArea" }) ); - expect(textArea.value).toEqual('{"A":"A"}'); + expect(await textAreaHarness.getValue()).toEqual('{"A":"A"}'); - component.noTypePolicyEditorComponent.formatJsonInput(); - expect(textArea.value).toEqual('{\n "A": "A"\n}'); - }); + let validJson: string; + component.noTypePolicyEditorComponent.validJson.subscribe( + (json: string) => { + validJson = json; + } + ); - it("should send valid json", async () => { const textArea = component.noTypePolicyEditorComponent.instanceForm.get( "policyJsonTextArea" ); - expect(textArea.value).toEqual('{"A":"A"}'); - - let validJson: string; - component.noTypePolicyEditorComponent.validJson.subscribe((json: string) => { - validJson = json; - }); - textArea.setValue('{"B":"B"}'); expect(validJson).toEqual('{"B":"B"}'); }); it("should send null when invalid json", async () => { - const textArea = component.noTypePolicyEditorComponent.instanceForm.get( - "policyJsonTextArea" + const textArea: MatInputHarness = await loader.getHarness( + MatInputHarness.with({ selector: "#policyJsonTextArea" }) ); - expect(textArea.value).toEqual('{"A":"A"}'); + expect(await textArea.getValue()).toEqual('{"A":"A"}'); let invalidJson: string; - component.noTypePolicyEditorComponent.validJson.subscribe((json: string) => { - invalidJson = json; - }); + component.noTypePolicyEditorComponent.validJson.subscribe( + (json: string) => { + invalidJson = json; + } + ); - textArea.setValue('{'); + textArea.setValue("{"); expect(invalidJson).toBeFalsy(); });