Skip to content

Commit

Permalink
fix: ut
Browse files Browse the repository at this point in the history
  • Loading branch information
anchenyi committed Oct 14, 2024
1 parent 9f09657 commit 36f6a6d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/fx-core/tests/client/tdpClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { ErrorNames } from "../../src/component/resource/botService/constants";
import { DeveloperPortalAPIFailedError } from "../../src/error/teamsApp";
import { Messages } from "../component/resource/botService/messages";
import { MockTools } from "../core/utils";
import { getDefaultString } from "../../src/common/localizeUtils";

describe("TeamsDevPortalClient Test", () => {
const tools = new MockTools();
Expand Down Expand Up @@ -401,6 +402,31 @@ describe("TeamsDevPortalClient Test", () => {
}
});

it("422 conflict with unknown data", async () => {
const fakeAxiosInstance = axios.create();
sandbox.stub(axios, "create").returns(fakeAxiosInstance);

const error = {
response: {
status: 422,
data: "Unknown",
},
};
sandbox.stub(fakeAxiosInstance, "post").throws(error);

try {
await teamsDevPortalClient.importApp(token, Buffer.from(""));
} catch (error) {
chai.assert.equal(error.name, DeveloperPortalAPIFailedError.name);
chai.assert.isFalse(
error.message.includes(AppStudioError.TeamsAppCreateConflictWithPublishedAppError.name)
);
chai.assert.isTrue(
error.message.includes(getDefaultString("error.appstudio.apiFailed.name.common"))
);
}
});

it("422 other error", async () => {
const fakeAxiosInstance = axios.create();
sandbox.stub(axios, "create").returns(fakeAxiosInstance);
Expand Down

0 comments on commit 36f6a6d

Please sign in to comment.