Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wenytang-ms committed Jan 24, 2025
1 parent b90ddad commit f0f2dcd
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/test/unit/azure/ApiCenterDefines/ApiCenterApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,33 @@ describe('Azure ApiCenter Defines ApiCenterApisDataplane', () => {
const res = api.getName();
assert.strictEqual("fakeName", res);
});
it('ApiCenterApisDataplane class getChild', async () => {
it("ApiCenterApisDataplane class getChild empty", async () => {
const api: ApiCenterApisDataplane = new ApiCenterApisDataplane(data);
sandbox.stub(ApiCenterDataPlaneService.prototype, "getApiCenterApis").resolves(undefined);
const res = await api.getChild(context as any, "fakeContent");
assert.strictEqual(res.length, 0);
});
it("ApiCenterApisDataplane class getChild with 1 api", async() => {
const api: ApiCenterApisDataplane = new ApiCenterApisDataplane(data);
sandbox.stub(ApiCenterDataPlaneService.prototype, "getApiCenterApis").resolves({
nextLink: "fakeNextLink",
value: [
{
name: "fakeName",
title: "fakeTitle",
kind: "fakeKind",
lifecycleStage: "fakeStage",
externalDocumentation: [],
contacts: [],
customProperties: {}
}
]
});
const res = await api.getChild(context as any, "fakeContent");
assert.strictEqual(res.length, 1);
assert.strictEqual(res[0].name, "fakeName");
assert.strictEqual(api.getNextLink(), "fakeNextLink");
});
});
describe('Azure ApiCenter Defines ApiCenterApiManagement', () => {
let sandbox = null as any;
Expand Down

0 comments on commit f0f2dcd

Please sign in to comment.