Skip to content

Commit fc93f44

Browse files
tobiasso85RandomByte
authored andcommitted
[INTERNAL] fix tests
1 parent ce1236d commit fc93f44

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

Diff for: lib/processors/themeBuilder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class ThemeBuilder {
6868

6969
const libParams = new Resource({
7070
path: themeDir + "/library-parameters.json",
71-
string: JSON.stringify(result.variables, null, compress || compressJSON ? null : "\t")
71+
string: JSON.stringify(result.variables, null, (compress || compressJSON) ? null : "\t")
7272
});
7373

7474
files.push(libCss, libCssRtl, libParams);

Diff for: lib/tasks/buildThemes.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,17 @@ module.exports = async function({workspace, dependencies, options}) {
5757

5858
resources = await allResources.filter(isAvailable);
5959
}
60+
61+
const compress = options.compress !== false;
6062
const processedResources = await themeBuilder({
6163
resources,
6264
fs: fsInterface(combo),
6365
options: {
64-
compressJSON: true
66+
compressJSON: compress,
67+
compress: false
6568
}
6669
});
6770

68-
const compress = options.compress === undefined ? true : options.compress;
6971
if (compress) {
7072
const cssResources = processedResources.filter((resource) => {
7173
return resource.getPath().endsWith(".css");

Diff for: test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/library-RTL.css

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"someColor":"#000"}
1+
{"someColor":"#000000"}

Diff for: test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/library.css

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: test/lib/tasks/buildThemes.js

+26-13
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ let buildThemes = require("../../../lib/tasks/buildThemes");
88
test.beforeEach((t) => {
99
// Stubbing processors/themeBuilder
1010
t.context.themeBuilderStub = sinon.stub();
11+
t.context.cssOptimizerStub = sinon.stub();
1112
t.context.fsInterfaceStub = sinon.stub(require("@ui5/fs"), "fsInterface");
1213
t.context.fsInterfaceStub.returns({});
1314
mock("../../../lib/processors/themeBuilder", t.context.themeBuilderStub);
15+
mock("../../../lib/processors/cssOptimizer", t.context.cssOptimizerStub);
1416

1517
// Re-require tested module
1618
buildThemes = mock.reRequire("../../../lib/tasks/buildThemes");
@@ -19,10 +21,11 @@ test.beforeEach((t) => {
1921
test.afterEach.always((t) => {
2022
t.context.fsInterfaceStub.restore();
2123
mock.stop("../../../lib/processors/themeBuilder");
24+
mock.stop("../../../lib/processors/cssOptimizer");
2225
});
2326

2427
test.serial("buildThemes", async (t) => {
25-
t.plan(6);
28+
t.plan(8);
2629

2730
const lessResource = {};
2831

@@ -37,9 +40,9 @@ test.serial("buildThemes", async (t) => {
3740
write: sinon.stub()
3841
};
3942

40-
const cssResource = {};
41-
const cssRtlResource = {};
42-
const jsonParametersResource = {};
43+
const cssResource = {getPath: () => "fu.css"};
44+
const cssRtlResource = {getPath: () => "fu-rtl.css"};
45+
const jsonParametersResource = {getPath: () => "fu.json"};
4346

4447
t.context.themeBuilderStub.returns([
4548
cssResource,
@@ -56,15 +59,22 @@ test.serial("buildThemes", async (t) => {
5659
});
5760

5861
t.deepEqual(t.context.themeBuilderStub.callCount, 1,
59-
"Processor should be called once");
62+
"Theme Builder should be called once");
6063

6164
t.deepEqual(t.context.themeBuilderStub.getCall(0).args[0], {
6265
resources: [lessResource],
6366
fs: {},
6467
options: {
65-
compress: true // default
68+
compressJSON: true, // default
69+
compress: false
6670
}
67-
}, "Processor should be called with expected arguments");
71+
}, "Theme Builder should be called with expected arguments");
72+
73+
t.deepEqual(t.context.cssOptimizerStub.callCount, 1, "CSS Optimizer should be called once");
74+
t.deepEqual(t.context.cssOptimizerStub.getCall(0).args[0], {
75+
resources: [cssResource, cssRtlResource],
76+
fs: {}
77+
}, "CSS Optimizer should be called with expected arguments");
6878

6979
t.deepEqual(workspace.write.callCount, 3,
7080
"workspace.write should be called 3 times");
@@ -75,7 +85,7 @@ test.serial("buildThemes", async (t) => {
7585

7686

7787
test.serial("buildThemes (compress = false)", async (t) => {
78-
t.plan(6);
88+
t.plan(7);
7989

8090
const lessResource = {};
8191

@@ -90,9 +100,9 @@ test.serial("buildThemes (compress = false)", async (t) => {
90100
write: sinon.stub()
91101
};
92102

93-
const cssResource = {};
94-
const cssRtlResource = {};
95-
const jsonParametersResource = {};
103+
const cssResource = {getPath: () => "fu.css"};
104+
const cssRtlResource = {getPath: () => "fu-rtl.css"};
105+
const jsonParametersResource = {getPath: () => "fu.json"};
96106

97107
t.context.themeBuilderStub.returns([
98108
cssResource,
@@ -110,15 +120,18 @@ test.serial("buildThemes (compress = false)", async (t) => {
110120
});
111121

112122
t.deepEqual(t.context.themeBuilderStub.callCount, 1,
113-
"Processor should be called once");
123+
"Theme Builder should be called once");
114124

115125
t.deepEqual(t.context.themeBuilderStub.getCall(0).args[0], {
116126
resources: [lessResource],
117127
fs: {},
118128
options: {
129+
compressJSON: false,
119130
compress: false
120131
}
121-
}, "Processor should be called with expected arguments");
132+
}, "Theme Builder should be called with expected arguments");
133+
134+
t.deepEqual(t.context.cssOptimizerStub.callCount, 0, "CSS Optimizer should not be called");
122135

123136
t.deepEqual(workspace.write.callCount, 3,
124137
"workspace.write should be called 3 times");

0 commit comments

Comments
 (0)