|
| 1 | +import { expect } from "chai"; |
| 2 | +import * as ui5ApiService from "../../../../core/ui5ApiService"; |
| 3 | +import * as stubber from "../../../support/stubber"; |
| 4 | +import * as vscode from "vscode"; |
| 5 | +import { ColumnListItemApiSymbol, BaseObjectApiSymbol } from "../../unit/common"; |
| 6 | + |
| 7 | +describe("ui5ApiBuffer tests", () => { |
| 8 | + before(() => { |
| 9 | + stubber.stubUI5Service(); |
| 10 | + }); |
| 11 | + |
| 12 | + after(() => { |
| 13 | + stubber.restore(); |
| 14 | + }); |
| 15 | + |
| 16 | + it("should return normalized name", () => { |
| 17 | + expect(ui5ApiService.getNormalizedName("module:sap/base/assert")).to.equal("sap.base.assert"); |
| 18 | + expect(ui5ApiService.getNormalizedName("sap/base/assert")).to.equal("sap.base.assert"); |
| 19 | + }); |
| 20 | + |
| 21 | + it("should return API doc URL", () => { |
| 22 | + expect( |
| 23 | + ui5ApiService.getUi5ObjectApiDocUrl("module:sap/base/assert", "http://somewhere") |
| 24 | + ).to.equal("http://somewhere/#/api/module%3Asap%2Fbase%2Fassert"); |
| 25 | + |
| 26 | + expect(ui5ApiService.getUi5ObjectApiDocUrl("sap/base/assert", "http://somewhere")).to.equal( |
| 27 | + "http://somewhere/#/api/sap/base/assert" |
| 28 | + ); |
| 29 | + }); |
| 30 | + |
| 31 | + it("should enhance API index node", () => { |
| 32 | + ui5ApiService.setApiBaseURL("http://somewhere"); |
| 33 | + |
| 34 | + const result = ui5ApiService.enhanceApiIndexNode({ |
| 35 | + name: "sap.m.Button", |
| 36 | + kind: "class", |
| 37 | + lib: "sap.m", |
| 38 | + displayName: "sap.m.Button", |
| 39 | + visibility: "public", |
| 40 | + }); |
| 41 | + |
| 42 | + expect(result.apiDocUrl).to.equal("http://somewhere/#/api/sap.m.Button"); |
| 43 | + expect(result.library).to.equal("sap.m"); |
| 44 | + expect(result.basename).to.equal("Button"); |
| 45 | + expect(result.name).to.equal("sap.m.Button"); |
| 46 | + expect(result.originalName).to.equal("sap.m.Button"); |
| 47 | + expect(result.kind).to.equal("class"); |
| 48 | + }); |
| 49 | +}); |
0 commit comments