Skip to content

Commit 2b20351

Browse files
matz3flovogt
authored andcommitted
[INTERNAL] Fix tests
- Ensure latest terser version (Related to 4789c20) - Mock Date methods to get a stable timestamp result Note: mocking a processor isn't easily possible as the @ui5/project builder is using its own @ui5/builder dependency.
1 parent 1b452d8 commit 2b20351

File tree

3 files changed

+7
-24
lines changed

3 files changed

+7
-24
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"rimraf": "^3.0.2",
121121
"semver": "^7.3.5",
122122
"sourcemap-codec": "^1.4.8",
123-
"terser": "^5.10.0",
123+
"terser": "^5.14.1",
124124
"xml2js": "^0.4.23",
125125
"yazl": "^2.5.1"
126126
},

test/lib/builder/builder.js

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const readFile = promisify(fs.readFile);
88
const assert = chai.assert;
99
const sinon = require("sinon");
1010
const mock = require("mock-require");
11-
const resourceFactory = require("@ui5/fs").resourceFactory;
1211

1312
const {generateProjectGraph} = require("@ui5/project");
1413
const builder = require("@ui5/project").builder;
@@ -513,27 +512,11 @@ test.serial("Build application.j with resources.json and version info", async (t
513512
const destPath = "./test/tmp/build/application.j/dest-resources-json";
514513
const expectedPath = path.join("test", "expected", "build", "application.j", "dest-resources-json");
515514

516-
517-
const dummyVersionInfoGenerator = () => {
518-
const versionJson = {
519-
"name": "application.j",
520-
"version": "1.0.0",
521-
"buildTimestamp": "202008120917",
522-
"scmRevision": "",
523-
"libraries": []
524-
};
525-
526-
return [resourceFactory.createResource({
527-
path: "/resources/sap-ui-version.json",
528-
string: JSON.stringify(versionJson, null, "\t")
529-
})];
530-
};
531-
532-
mock("../../../lib/processors/versionInfoGenerator", dummyVersionInfoGenerator);
533-
mock.reRequire("../../../lib/tasks/generateVersionInfo");
534-
535-
// TODO: Is this still required? If so, the @ui5/project build needs to be re-required
536-
// const builder = mock.reRequire("../../../lib/builder/builder");
515+
sinon.stub(Date.prototype, "getFullYear").returns(2020);
516+
sinon.stub(Date.prototype, "getMonth").returns(7);
517+
sinon.stub(Date.prototype, "getDate").returns(12);
518+
sinon.stub(Date.prototype, "getHours").returns(9);
519+
sinon.stub(Date.prototype, "getMinutes").returns(17);
537520

538521
const graph = await generateProjectGraph.usingObject({
539522
dependencyTree: applicationJTree

0 commit comments

Comments
 (0)