Skip to content

Commit 272d71b

Browse files
committed
[INTERNAL] Enable test for transformApiJson script
1 parent d811a1d commit 272d71b

File tree

4 files changed

+67
-3
lines changed

4 files changed

+67
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"text-summary"
8080
],
8181
"exclude": [
82-
"lib/processors/jsdoc/lib/**",
82+
"lib/processors/jsdoc/lib/ui5/template/**",
8383
"docs/**",
8484
"jsdocs/**",
8585
"coverage/**",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"namespace","name":"library.j","basename":"j","resource":"library/j/some.js","module":"library/j/some","static":true,"visibility":"public","displayName":"library.j","nodes":[{"name":"library.j.aaa","description":"","href":"api/library.j.aaa"},{"name":"library.j.Foo","description":"<p>My super documentation of this class</p>","href":"api/library.j.Foo"}],"title":"namespace library.j","subTitle":""},{"kind":"class","name":"library.j.aaa","basename":"aaa","resource":"library/j/dependency-es6-2.js","module":"library/j/dependency-es6-2","export":"","static":true,"visibility":"public","since":"1.22","extends":"library.j.a","ui5-metamodel":true,"ui5-metadata":{"properties":[{"name":"MyProp","type":"boolean","defaultValue":false,"group":"undefined","visibility":"public","since":"1.46","description":"<p>MyProp property<br><br><i>Since: 1.46.</i></p>","methods":["getMyProp","setMyProp"]}]},"constructor":{"visibility":"public","parameters":[{"name":"sId","optional":true,"description":"<p>ID for the new control, generated automatically if no ID is given</p>","phoneName":"sId","depth":0,"types":[{"name":"string","linkEnabled":false}],"defaultValue":""},{"name":"mSettings","optional":true,"description":"<p>Initial settings for the new control</p>","phoneName":"mSettings","depth":0,"types":[{"name":"object","linkEnabled":false}],"defaultValue":""}],"description":"<p>Constructor for a new library.j.aaa.</p>","references":[],"codeExample":"<pre>new library.j.aaa(sId?, mSettings?)</pre>"},"methods":[{"name":"library.j.aaa.extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"<p>Created class / constructor function</p>","types":[{"value":"function"}]},"parameters":[{"name":"sClassName","optional":false,"description":"<p>Name of the class being created</p>","types":[{"value":"string"}],"defaultValue":""},{"name":"oClassInfo","optional":true,"description":"<p>Object literal with information about the class</p>","types":[{"value":"object"}],"defaultValue":""},{"name":"FNMetaImpl","optional":true,"description":"<p>Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class</p>","types":[{"value":"function"}],"defaultValue":""}],"description":"<p>Creates a new subclass of class library.j.aaa with name <code>sClassName</code> and enriches it with the information contained in <code>oClassInfo</code>.</p><p><code>oClassInfo</code> might contain the same kind of information as described in <a target=\"_self\" href=\"api/library.j.a#methods/library.j.a.extend\">library.j.a.extend</a>.</p>","href":"api/library.j.aaa#methods/library.j.aaa.extend","code":"<pre>library.j.aaa.extend(sClassName, oClassInfo?, FNMetaImpl?) : function</pre>"},{"name":"library.j.aaa.getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"<p>Metadata object describing this class</p>","types":[{"value":"sap.ui.base.Metadata","href":"api/sap.ui.base.Metadata","linkEnabled":true}]},"description":"<p>Returns a metadata object for class library.j.aaa.</p>","href":"api/library.j.aaa#methods/library.j.aaa.getMetadata","code":"<pre>library.j.aaa.getMetadata() : sap.ui.base.Metadata</pre>"},{"name":"getMyProp","visibility":"public","since":"1.46","returnValue":{"type":"boolean","description":"<p>Value of property <code>MyProp</code></p>","types":[{"value":"boolean"}]},"description":"<p>Gets current value of property <a target=\"_self\" href=\"api/library.j.aaa#methods/getMyProp\">MyProp</a>.</p><p>MyProp property</p><p>Default value is <code>false</code>.</p>","href":"api/library.j.aaa#methods/getMyProp","code":"<pre>getMyProp() : boolean</pre>"},{"name":"setMyProp","visibility":"public","since":"1.46","returnValue":{"type":"this","description":"<p>Reference to <code>this</code> in order to allow method chaining</p>","types":[{"value":"this"}]},"parameters":[{"name":"bMyProp","optional":true,"defaultValue":false,"description":"<p>New value for property <code>MyProp</code></p>","types":[{"value":"boolean"}]}],"description":"<p>Sets a new value for property <a target=\"_self\" href=\"api/library.j.aaa#methods/getMyProp\">MyProp</a>.</p><p>MyProp property</p><p>When called with a value of <code>null</code> or <code>undefined</code>, the default value of the property will be restored.</p><p>Default value is <code>false</code>.</p>","href":"api/library.j.aaa#methods/setMyProp","code":"<pre>setMyProp(bMyProp?) : this</pre>"}],"displayName":"library.j.aaa","title":"class library.j.aaa","subTitle":""},{"kind":"class","name":"library.j.Foo","basename":"Foo","resource":"library/j/dependency-es6-1.js","module":"library/j/dependency-es6-1","static":true,"visibility":"public","extends":"library.j.Bar","description":"<p>My super documentation of this class</p>","constructor":{"visibility":"public","references":[],"codeExample":"<pre>new library.j.Foo()</pre>"},"displayName":"library.j.Foo","title":"class library.j.Foo","subTitle":""},{"name":"library","displayName":"library","kind":"namespace","nodes":[{"name":"library.j","description":"","href":"api/library.j"}],"title":"namespace library","subTitle":""}]}

test/lib/builder/builder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,8 +890,7 @@ test.serial("Build library.j with JSDoc build only", async (t) => {
890890
graph.setTaskRepository(taskRepository);
891891
await graph.build({
892892
destPath,
893-
includedTasks: ["generateJsdoc"],
894-
excludedTasks: ["*"]
893+
jsdoc: true
895894
});
896895

897896
const expectedFiles = await findFiles(expectedPath);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import test from "ava";
2+
import esmock from "esmock";
3+
import sinonGlobal from "sinon";
4+
5+
test.beforeEach(async (t) => {
6+
t.context.sinon = sinonGlobal.createSandbox();
7+
t.context.transformApiJson = await esmock("../../../../../lib/processors/jsdoc/lib/transformApiJson.cjs");
8+
});
9+
10+
test.afterEach.always((t) => {
11+
t.context.sinon.restore();
12+
});
13+
14+
test("Basic test without symbols", async (t) => {
15+
const {sinon, transformApiJson} = t.context;
16+
17+
const apiJsonPath = "/test-resources/sap/ui5/tooling/test/designtime/api.json";
18+
const fakeTargetPath = "/ignore/this/path/resource/will/be/returned";
19+
const dotLibraryPath = "/resources/sap/ui5/tooling/test/.library";
20+
const dependencyApiJsonPaths = [
21+
"/resources/some/path/x/api.json",
22+
"/resources/some/path/y/api.json"
23+
];
24+
25+
const fs = {
26+
readFile: sinon.stub().yieldsAsync(new Error("Not found!"))
27+
.withArgs("/some/path/.library").yieldsAsync(null, `
28+
<?xml version="1.0" encoding="UTF-8" ?>
29+
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >
30+
31+
<name>sap.ui5.tooling.test</name>
32+
<vendor>SAP SE</vendor>
33+
<copyright>Some copyright notice</copyright>
34+
<version>1.2.3</version>
35+
36+
<documentation>UI5 Tooling Test Library</documentation>
37+
38+
</library>`)
39+
.withArgs("/test-resources/sap/ui5/tooling/test/designtime/api.json").yieldsAsync(null, JSON.stringify(
40+
{
41+
"$schema-ref": "http://schemas.sap.com/sapui5/designtime/api.json/1.0",
42+
"version": "1.2.3",
43+
"library": "sap.ui5.tooling.test",
44+
"symbols": []
45+
}
46+
)),
47+
48+
readdir: sinon.stub().yieldsAsync(new Error("Not found!"))
49+
};
50+
51+
const apiJsonContent = await transformApiJson(
52+
apiJsonPath, fakeTargetPath, dotLibraryPath, dependencyApiJsonPaths, "", {
53+
fs,
54+
returnOutputFiles: true
55+
}
56+
);
57+
58+
t.is(apiJsonContent, JSON.stringify({
59+
"$schema-ref": "http://schemas.sap.com/sapui5/designtime/api.json/1.0",
60+
"version": "1.2.3",
61+
"library": "sap.ui5.tooling.test",
62+
"symbols": []
63+
}));
64+
});

0 commit comments

Comments
 (0)