Skip to content

Commit 95b00c4

Browse files
committed
[INTERNAL] Add very basic test for inlineCssVariables=true
1 parent 77e0ebb commit 95b00c4

File tree

8 files changed

+117
-2
lines changed

8 files changed

+117
-2
lines changed

lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ Builder.prototype.build = function(options) {
356356
}
357357

358358
if (options.inlineCssVariables === true) {
359-
result.css = result.cssVariables + result.css;
359+
result.css = result.cssVariables + "\n" + result.css;
360360
if (options.rtl) {
361-
result.cssRtl = result.cssVariables + result.cssRtl;
361+
result.cssRtl = result.cssVariables + "\n" + result.cssRtl;
362362
}
363363
}
364364

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.myOtherUiLibRule1 {
2+
color: #ffffff;
3+
}
4+
.myOtherUiLibRule2 {
5+
padding: 1px 4px 3px 2px;
6+
}
7+
.barContrast.myOtherUiLibRule1,
8+
.barContrast .myOtherUiLibRule1 {
9+
color: #000000;
10+
}
11+
12+
/* Inline theming parameters */
13+
#sap-ui-theme-my\.other\.ui\.lib{background-image:url('data:text/plain;utf-8,%7B%22default%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyControl_color2%22%3A%22%23008000%22%7D%2C%22scopes%22%3A%7B%22barContrast%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23000000%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23000000%22%7D%7D%7D')}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.myOtherUiLibRule1 {
2+
color: #ffffff;
3+
}
4+
.myOtherUiLibRule2 {
5+
padding: 1px 2px 3px 4px;
6+
}
7+
.barContrast.myOtherUiLibRule1,
8+
.barContrast .myOtherUiLibRule1 {
9+
color: #000000;
10+
}
11+
12+
/* Inline theming parameters */
13+
#sap-ui-theme-my\.other\.ui\.lib{background-image:url('data:text/plain;utf-8,%7B%22default%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyControl_color2%22%3A%22%23008000%22%7D%2C%22scopes%22%3A%7B%22barContrast%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23000000%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23000000%22%7D%7D%7D')}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
:root {
2+
--_my_other_ui_lib_MyControl_color1: var(--color1);
3+
--_my_other_ui_lib_MyOtherControl_color1: var(--color1);
4+
}
5+
6+
.myOtherUiLibRule1 {
7+
color: #fefefe;
8+
}
9+
.myOtherUiLibRule2 {
10+
padding: 1px 4px 3px 2px;
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
:root {
2+
--_my_other_ui_lib_MyControl_color1: var(--color1);
3+
--_my_other_ui_lib_MyOtherControl_color1: var(--color1);
4+
}
5+
6+
.myOtherUiLibRule1 {
7+
color: #fefefe;
8+
}
9+
.myOtherUiLibRule2 {
10+
padding: 1px 2px 3px 4px;
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.myOtherUiLibRule1 {
2+
color: #ffffff;
3+
}
4+
.myOtherUiLibRule2 {
5+
padding: 1px 4px 3px 2px;
6+
}
7+
.fooContrast.myOtherUiLibRule1,
8+
.fooContrast .myOtherUiLibRule1 {
9+
color: #000000;
10+
}
11+
12+
/* Inline theming parameters */
13+
#sap-ui-theme-my\.other\.ui\.lib{background-image:url('data:text/plain;utf-8,%7B%22default%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyControl_color2%22%3A%22%23008000%22%7D%2C%22scopes%22%3A%7B%22fooContrast%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23000000%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23000000%22%7D%7D%7D')}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.myOtherUiLibRule1 {
2+
color: #ffffff;
3+
}
4+
.myOtherUiLibRule2 {
5+
padding: 1px 2px 3px 4px;
6+
}
7+
.fooContrast.myOtherUiLibRule1,
8+
.fooContrast .myOtherUiLibRule1 {
9+
color: #000000;
10+
}
11+
12+
/* Inline theming parameters */
13+
#sap-ui-theme-my\.other\.ui\.lib{background-image:url('data:text/plain;utf-8,%7B%22default%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23ffffff%22%2C%22_my_other_ui_lib_MyControl_color2%22%3A%22%23008000%22%7D%2C%22scopes%22%3A%7B%22fooContrast%22%3A%7B%22_my_other_ui_lib_MyControl_color1%22%3A%22%23000000%22%2C%22_my_other_ui_lib_MyOtherControl_color1%22%3A%22%23000000%22%7D%7D%7D')}

test/test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,47 @@ describe("libraries (my/other/ui/lib)", function() {
380380
});
381381
});
382382

383+
describe("inlineCssVariables / inlineThemingParameters", function() {
384+
it("should create base theme (inlineCssVariables: true / inlineThemingParameters: false)", function() {
385+
return new Builder().build({
386+
lessInputPath: "my/other/ui/lib/themes/base/library.source.less",
387+
rootPaths: [
388+
"test/fixtures/libraries/lib1",
389+
"test/fixtures/libraries/lib3"
390+
],
391+
library: {
392+
name: "my.other.ui.lib"
393+
},
394+
inlineCssVariables: true,
395+
inlineThemingParameters: false
396+
}).then(function(result) {
397+
assert.strictEqual(result.css, readFile("test/expected/inlineCssVariables/lib3/my/other/ui/lib/themes/base/library.css"), "css should be correctly generated.");
398+
assert.strictEqual(result.cssRtl, readFile("test/expected/inlineCssVariables/lib3/my/other/ui/lib/themes/base/library-RTL.css"), "rtl css should be correctly generated.");
399+
assert.deepStrictEqual(result.variables, {
400+
"_my_other_ui_lib_MyControl_color1": "#fefefe",
401+
"_my_other_ui_lib_MyOtherControl_color1": "#fefefe"
402+
}, "variables should be correctly collected.");
403+
assert.deepStrictEqual(result.allVariables, {
404+
"_my_other_ui_lib_MyControl_color1": "#fefefe",
405+
"_my_other_ui_lib_MyOtherControl_color1": "#fefefe",
406+
"color1": "#fefefe"
407+
}, "allVariables should be correctly collected.");
408+
assert.deepStrictEqual(result.imports, [
409+
path.join("test", "fixtures", "libraries", "lib3", "my", "other", "ui", "lib", "themes", "base", "library.source.less"),
410+
path.join("test", "fixtures", "libraries", "lib1", "my", "ui", "lib", "themes", "base", "global.less"),
411+
path.join("test", "fixtures", "libraries", "lib3", "my", "other", "ui", "lib", "themes", "base", "MyControl.less"),
412+
path.join("test", "fixtures", "libraries", "lib3", "my", "other", "ui", "lib", "themes", "base", "sub-directory", "MyOtherControl.less")
413+
], "import list should be correct.");
414+
415+
// When using inlineCssVariables=true without cssVariables=true, there shouldn't be additional files exposed
416+
assert.strictEqual(result.cssSkeleton, undefined);
417+
assert.strictEqual(result.cssSkeletonRtl, undefined);
418+
// assert.strictEqual(result.cssVariables, undefined); // TODO
419+
assert.strictEqual(result.cssVariablesSource, undefined);
420+
});
421+
});
422+
});
423+
383424
describe("error handling", function() {
384425
it("should have correct error in case of undefined variable usage (lessInput)", function() {
385426
return new Builder().build({

0 commit comments

Comments
 (0)