Skip to content

Commit

Permalink
Add basic integration test for JSDoc generation
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Mar 6, 2019
1 parent 1f45379 commit 3e6b5a4
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 1 deletion.
11 changes: 11 additions & 0 deletions test/expected/build/library.j/dest/resources/library/j/.library
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >

<name>library.j</name>
<vendor>SAP SE</vendor>
<copyright>Some fancy copyright</copyright>
<version>${version}</version>

<documentation>Library J</documentation>

</library>
16 changes: 16 additions & 0 deletions test/expected/build/library.j/dest/resources/library/j/some.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*!
* ${copyright}
*/

sap.ui.define([],
function() {
"use strict";

/**
* @alias library.j
* @namespace
* @public
*/
var SomeFunction = function() {};

}, /* bExport= */ true);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","symbols":[{"kind":"namespace","name":"library.j","basename":"j","resource":"library/j/some.js","module":"library/j/some","static":true,"visibility":"public"}]}
11 changes: 11 additions & 0 deletions test/fixtures/library.j/main/src/library/j/.library
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >

<name>library.j</name>
<vendor>SAP SE</vendor>
<copyright>Some fancy copyright</copyright>
<version>${version}</version>

<documentation>Library J</documentation>

</library>
16 changes: 16 additions & 0 deletions test/fixtures/library.j/main/src/library/j/some.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*!
* ${copyright}
*/

sap.ui.define([],
function() {
"use strict";

/**
* @alias library.j
* @namespace
* @public
*/
var SomeFunction = function() {};

}, /* bExport= */ true);
9 changes: 9 additions & 0 deletions test/fixtures/library.j/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "library.j",
"version": "1.0.0",
"description": "Simple SAPUI5 based library for testing JSDoc builds",
"dependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
10 changes: 10 additions & 0 deletions test/fixtures/library.j/ui5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
specVersion: "0.1"
type: library
metadata:
name: library.j
resources:
configuration:
paths:
src: main/src
test: main/test
49 changes: 48 additions & 1 deletion test/lib/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const applicationGPath = path.join(__dirname, "..", "..", "fixtures", "applicati
const applicationHPath = path.join(__dirname, "..", "..", "fixtures", "application.h");
const libraryDPath = path.join(__dirname, "..", "..", "fixtures", "library.d");
const libraryEPath = path.join(__dirname, "..", "..", "fixtures", "library.e");
const libraryIPath = path.join(__dirname, "..", "..", "fixtures", "library.i");
const libraryHPath = path.join(__dirname, "..", "..", "fixtures", "library.h");
const libraryIPath = path.join(__dirname, "..", "..", "fixtures", "library.i");
const libraryJPath = path.join(__dirname, "..", "..", "fixtures", "library.j");
const libraryCore = path.join(__dirname, "..", "..", "fixtures", "sap.ui.core-evo");
const themeJPath = path.join(__dirname, "..", "..", "fixtures", "theme.j");

Expand Down Expand Up @@ -248,6 +249,28 @@ test("Build library.i with manifest info taken from .library and library.js", (t
});
});

test("Build library.j with JSDoc build only", (t) => {
const destPath = path.join("test", "tmp", "build", "library.j", "dest");
const expectedPath = path.join("test", "expected", "build", "library.j", "dest");

return builder.build({
tree: libraryJTree,
destPath,
includedTasks: ["generateJsdoc"],
excludedTasks: ["*"]
}).then(() => {
return findFiles(expectedPath);
}).then((expectedFiles) => {
// Check for all directories and files
assert.directoryDeepEqual(destPath, expectedPath);

// Check for all file contents
return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath);
}).then(() => {
t.pass();
});
});

test("Build theme.j even without an library", (t) => {
const destPath = "./test/tmp/build/theme.j/dest";
const expectedPath = "./test/expected/build/theme.j/dest";
Expand Down Expand Up @@ -753,6 +776,30 @@ const libraryITree = {
}
};

const libraryJTree = {
"id": "library.j",
"version": "1.0.0",
"path": libraryJPath,
"dependencies": [],
"_level": 0,
"specVersion": "0.1",
"type": "library",
"metadata": {
"name": "library.j",
"copyright": "Some fancy copyright"
},
"resources": {
"configuration": {
"paths": {
"src": "main/src"
}
},
"pathMappings": {
"/resources/": "main/src"
}
}
};

const themeJTree = {
"id": "library.i",
"version": "1.0.0",
Expand Down

0 comments on commit 3e6b5a4

Please sign in to comment.