@@ -7,11 +7,32 @@ const assert = require("assert");
7
7
const CSSVariablesCollectorPlugin = require ( "../lib/plugin/css-variables-collector" ) ;
8
8
9
9
describe ( "CSSVariablesCollectorPlugin.getResolvedUrl" , function ( ) {
10
- it ( "should resolve relative url to ui5:// url" , function ( ) {
10
+ it ( "should resolve relative url to ui5:// url (filename with /resources/ - UI5 Tooling) " , function ( ) {
11
11
assert . strictEqual (
12
12
CSSVariablesCollectorPlugin . getResolvedUrl ( {
13
13
rawUrl : "img/foo.png" ,
14
- filename : "/resources/sap/ui/foo/themes/base/Foo.less"
14
+ filename : "/resources/sap/ui/foo/themes/base/Foo.less" ,
15
+ libraryName : "sap.ui.foo"
16
+ } ) ,
17
+ "ui5://sap/ui/foo/themes/base/img/foo.png"
18
+ ) ;
19
+ } ) ;
20
+ it ( "should resolve relative url to ui5:// url (filename with / - grunt-openui5/connect-openui5)" , function ( ) {
21
+ assert . strictEqual (
22
+ CSSVariablesCollectorPlugin . getResolvedUrl ( {
23
+ rawUrl : "img/foo.png" ,
24
+ filename : "/sap/ui/foo/themes/base/Foo.less" ,
25
+ libraryName : "sap.ui.foo"
26
+ } ) ,
27
+ "ui5://sap/ui/foo/themes/base/img/foo.png"
28
+ ) ;
29
+ } ) ;
30
+ it ( "should resolve relative url to ui5:// url (filename absolute fs path - custom usage)" , function ( ) {
31
+ assert . strictEqual (
32
+ CSSVariablesCollectorPlugin . getResolvedUrl ( {
33
+ rawUrl : "img/foo.png" ,
34
+ filename : "/Users/root/sap/ui/foo/themes/base/Foo.less" ,
35
+ libraryName : "sap.ui.foo"
15
36
} ) ,
16
37
"ui5://sap/ui/foo/themes/base/img/foo.png"
17
38
) ;
@@ -20,7 +41,8 @@ describe("CSSVariablesCollectorPlugin.getResolvedUrl", function() {
20
41
assert . strictEqual (
21
42
CSSVariablesCollectorPlugin . getResolvedUrl ( {
22
43
rawUrl : "/assets/img/foo.png" ,
23
- filename : "/resources/sap/ui/foo/themes/base/Foo.less"
44
+ filename : "/resources/sap/ui/foo/themes/base/Foo.less" ,
45
+ libraryName : "sap.ui.foo"
24
46
} ) ,
25
47
"/assets/img/foo.png"
26
48
) ;
@@ -29,9 +51,20 @@ describe("CSSVariablesCollectorPlugin.getResolvedUrl", function() {
29
51
assert . strictEqual (
30
52
CSSVariablesCollectorPlugin . getResolvedUrl ( {
31
53
rawUrl : "http://example.com/assets/img/foo.png" ,
32
- filename : "/resources/sap/ui/foo/themes/base/Foo.less"
54
+ filename : "/resources/sap/ui/foo/themes/base/Foo.less" ,
55
+ libraryName : "sap.ui.foo"
33
56
} ) ,
34
57
"http://example.com/assets/img/foo.png"
35
58
) ;
36
59
} ) ;
60
+ it ( "Error: should return null when library namespace is not part of filename" , function ( ) {
61
+ assert . strictEqual (
62
+ CSSVariablesCollectorPlugin . getResolvedUrl ( {
63
+ rawUrl : "img/foo.png" ,
64
+ filename : "/resources/sap/ui/foo/themes/base/Foo.less" ,
65
+ libraryName : "sap.ui.bar"
66
+ } ) ,
67
+ null
68
+ ) ;
69
+ } ) ;
37
70
} ) ;
0 commit comments