Skip to content

Commit

Permalink
test: ut
Browse files Browse the repository at this point in the history
  • Loading branch information
jayzhang committed Jun 22, 2024
1 parent 2682488 commit 5bc6d94
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/vscode-extension/test/handlers/manifestHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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")
Expand All @@ -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());
});
});
});

0 comments on commit 5bc6d94

Please sign in to comment.