From 5bc6d94cf2d79595a23890ac6876751c407e75fa Mon Sep 17 00:00:00 2001 From: huajiezhang Date: Sat, 22 Jun 2024 11:34:39 +0800 Subject: [PATCH] test: ut --- .../test/handlers/manifestHandlers.test.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/vscode-extension/test/handlers/manifestHandlers.test.ts b/packages/vscode-extension/test/handlers/manifestHandlers.test.ts index 9ba67ebca0..185e3623d9 100644 --- a/packages/vscode-extension/test/handlers/manifestHandlers.test.ts +++ b/packages/vscode-extension/test/handlers/manifestHandlers.test.ts @@ -55,8 +55,11 @@ describe("Manifest handlers", () => { .resolves(ok({ type: "success", result: "test.zip" })); sandbox.stub(fs, "pathExists").resolves(true); sandbox.stub(fs, "readdir").resolves(["test.zip", "test.json"] as any); + sandbox.stub(fs, "existsSync").returns(true); const res = await publishInDeveloperPortalHandler(); assert.isTrue(res.isOk()); + const res2 = await publishInDeveloperPortalHandler(); + assert.isTrue(res2.isOk()); }); it("publish in developer portal - cancelled", async () => { @@ -95,7 +98,7 @@ describe("Manifest handlers", () => { }); describe("updatePreviewManifest", () => { - it("updatePreviewManifest", async () => { + it("happy", async () => { sandbox.stub(globalVariables, "core").value(new MockCore()); const openTextDocumentStub = sandbox .stub(vscode.workspace, "openTextDocument") @@ -104,5 +107,13 @@ describe("Manifest handlers", () => { await updatePreviewManifest([]); assert.isTrue(openTextDocumentStub.calledOnce); }); + it("getSelectedEnv error", async () => { + const core = new MockCore(); + sandbox.stub(globalVariables, "core").value(core); + sandbox.stub(core, "getSelectedEnv").resolves(err(new UserCancelError("VSC"))); + sandbox.stub(shared, "runCommand").resolves(ok(undefined)); + const res = await updatePreviewManifest([]); + assert.isTrue(res.isErr()); + }); }); });