From 36f6a6d310d54313ef6eedfa58453090dc100543 Mon Sep 17 00:00:00 2001 From: Chenyi An Date: Mon, 14 Oct 2024 11:08:13 +0800 Subject: [PATCH] fix: ut --- .../fx-core/tests/client/tdpClient.test.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/fx-core/tests/client/tdpClient.test.ts b/packages/fx-core/tests/client/tdpClient.test.ts index 68de44a60e..084bd13977 100644 --- a/packages/fx-core/tests/client/tdpClient.test.ts +++ b/packages/fx-core/tests/client/tdpClient.test.ts @@ -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(); @@ -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);