Skip to content

Commit e534189

Browse files
committed
Fix tests II
1 parent c4820dd commit e534189

File tree

8 files changed

+43
-22
lines changed

8 files changed

+43
-22
lines changed

lib/tasks/bundlers/generateFlexChangesBundle.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateFle
22
const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler");
33
const semver = require("semver");
44

5+
/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
56
/**
67
* Task to create changesBundle.json file containing all changes stored in the /changes folder for easier consumption
78
* at runtime.
@@ -16,10 +17,13 @@ const semver = require("semver");
1617
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
1718
* @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
1819
* @param {object} [parameters.options] Options
19-
* @param {string} [parameters.options.namespace] Application Namespace
20+
* @param {string} [parameters.options.projectNamespace] Project Namespace
2021
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
2122
*/
22-
module.exports = async function({workspace, taskUtil, options: {namespace}}) {
23+
module.exports = async function({workspace, taskUtil, options = {}}) {
24+
// Backward compatibility: "namespace" option got renamed to "projectNamespace"
25+
const namespace = options.projectNamespace || options.namespace;
26+
2327
// Use the given namespace if available, otherwise use no namespace
2428
// (e.g. in case no manifest.json is present)
2529
let pathPrefix = "";

lib/tasks/generateCachebusterInfo.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function getSigner(type) {
2828
}
2929
}
3030

31+
/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
3132
/**
3233
* Task to generate the application cachebuster info file.
3334
*
@@ -36,11 +37,15 @@ function getSigner(type) {
3637
* @param {object} parameters Parameters
3738
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
3839
* @param {object} parameters.options Options
39-
* @param {string} parameters.options.namespace Namespace of the application
40+
* @param {string} parameters.options.projectNamespace Namespace of the application
4041
* @param {string} [parameters.options.signatureType='time'] Type of signature to be used ('time' or 'hash')
4142
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
4243
*/
43-
module.exports = function({workspace, options: {namespace, signatureType}}) {
44+
module.exports = function({workspace, options}) {
45+
const {signatureType} = options;
46+
// Backward compatibility: "namespace" option got renamed to "projectNamespace"
47+
const namespace = options.projectNamespace || options.namespace;
48+
4449
const basePath = `/resources/${namespace}/`;
4550
return workspace.byGlob(`/resources/${namespace}/**/*`)
4651
.then(async (resources) => {

lib/tasks/generateLibraryManifest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = function({workspace, taskUtil, options: {projectName}}) {
4747
namespace: libraryNamespace,
4848
resources,
4949
getProjectVersion: (projectName) => {
50-
return taskUtil.getProject(projectName)?.getVersion();
50+
return taskUtil?.getProject(projectName)?.getVersion();
5151
},
5252
options: {
5353
}

lib/tasks/generateThemeDesignerResources.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ async function generateCssVariablesLess({workspace, combo, namespace}) {
187187
}
188188
}
189189

190+
/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
190191
/**
191192
* Generates resources required for integration with the SAP Theme Designer.
192193
*
@@ -198,11 +199,16 @@ async function generateCssVariablesLess({workspace, combo, namespace}) {
198199
* @param {object} parameters.options Options
199200
* @param {string} parameters.options.projectName Project name
200201
* @param {string} parameters.options.version Project version
201-
* @param {string} [parameters.options.namespace] If the project is of type <code>library</code>, provide its namespace.
202+
* @param {string} [parameters.options.projectNamespace] If the project is of type <code>library</code>,
203+
* provide its namespace.
202204
* Omit for type <code>theme-library</code>
203205
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
204206
*/
205-
module.exports = async function({workspace, dependencies, options: {projectName, version, namespace}}) {
207+
module.exports = async function({workspace, dependencies, options}) {
208+
const {projectName, version} = options;
209+
// Backward compatibility: "namespace" option got renamed to "projectNamespace"
210+
const namespace = options.projectNamespace || options.namespace;
211+
206212
// Skip sap.ui.documentation since it is not intended to be available in SAP Theme Designer to create custom themes
207213
if (namespace === "sap/ui/documentation") {
208214
return;

lib/tasks/transformBootstrapHtml.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const log = require("@ui5/logger").getLogger("builder:tasks:transformBootstrapHtml");
22
const bootstrapHtmlTransformer = require("../processors/bootstrapHtmlTransformer");
33

4+
/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
45
/**
56
* Task for transforming the application bootstrap HTML file.
67
*
@@ -12,7 +13,11 @@ const bootstrapHtmlTransformer = require("../processors/bootstrapHtmlTransformer
1213
* @param {string} [parameters.options.namespace] Project namespace
1314
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
1415
*/
15-
module.exports = async function({workspace, options: {projectName, namespace}}) {
16+
module.exports = async function({workspace, options}) {
17+
const {projectName} = options;
18+
// Backward compatibility: "namespace" option got renamed to "projectNamespace"
19+
const namespace = options.projectNamespace || options.namespace;
20+
1621
let indexPath;
1722
if (namespace) {
1823
indexPath = `/resources/${namespace}/index.html`;

test/lib/processors/versionInfoGenerator.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ test.beforeEach((t) => {
1616
t.context.warnLogStub = sinon.stub();
1717
t.context.infoLogStub = sinon.stub();
1818
t.context.verboseLogStub = sinon.stub();
19+
t.context.sillyLogStub = sinon.stub();
1920
sinon.stub(logger, "getLogger").returns({
2021
warn: t.context.warnLogStub,
2122
info: t.context.infoLogStub,
2223
verbose: t.context.verboseLogStub,
24+
silly: t.context.sillyLogStub,
2325
isLevelEnabled: () => true
2426
});
2527
versionInfoGenerator = mock.reRequire("../../../lib/processors/versionInfoGenerator");

test/lib/tasks/generateLibraryManifest.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,8 @@ function createWorkspace() {
88
return resourceFactory.createAdapter({
99
virBasePath: "/",
1010
project: {
11-
metadata: {
12-
name: "test.lib"
13-
},
14-
version: "2.0.0",
15-
dependencies: [
16-
{
17-
metadata: {
18-
name: "sap.ui.core"
19-
},
20-
version: "1.0.0"
21-
}
22-
]
11+
getName: () => "test.lib",
12+
getVersion: () => "2.0.0",
2313
}
2414
});
2515
}
@@ -31,6 +21,13 @@ async function assertCreatedManifest(t, oExpectedManifest) {
3121

3222
await generateLibraryManifest({
3323
workspace,
24+
taskUtil: {
25+
getProject: () => {
26+
return {
27+
getVersion: () => "1.0.0"
28+
};
29+
}
30+
},
3431
options: {
3532
projectName: "Test Lib"
3633
}

test/lib/tasks/generateVersionInfo.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ test.beforeEach((t) => {
9898
t.context.errorLogStub = sinon.stub();
9999
t.context.warnLogStub = sinon.stub();
100100
t.context.infoLogStub = sinon.stub();
101+
t.context.sillyLogStub = sinon.stub();
101102
sinon.stub(logger, "getLogger").returns({
102103
verbose: t.context.verboseLogStub,
103104
error: t.context.errorLogStub,
104105
warn: t.context.warnLogStub,
105106
info: t.context.infoLogStub,
107+
silly: t.context.sillyLogStub,
106108
isLevelEnabled: () => true
107109
});
108110
mock.reRequire("../../../lib/processors/versionInfoGenerator");
@@ -149,8 +151,8 @@ test.serial("integration: Library without i18n bundle file", async (t) => {
149151
"version": "1.33.7",
150152
}, oOptions);
151153

152-
t.is(t.context.verboseLogStub.callCount, 7);
153-
t.is(t.context.verboseLogStub.getCall(3).args[0],
154+
t.is(t.context.verboseLogStub.callCount, 4);
155+
t.is(t.context.verboseLogStub.getCall(1).args[0],
154156
"Cannot add meta information for library 'test.lib3'. The manifest.json file cannot be found");
155157
});
156158

0 commit comments

Comments
 (0)