@@ -7,11 +7,32 @@ const assert = require("assert");
77const CSSVariablesCollectorPlugin = require ( "../lib/plugin/css-variables-collector" ) ;
88
99describe ( "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 ( ) {
1111 assert . strictEqual (
1212 CSSVariablesCollectorPlugin . getResolvedUrl ( {
1313 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"
1536 } ) ,
1637 "ui5://sap/ui/foo/themes/base/img/foo.png"
1738 ) ;
@@ -20,7 +41,8 @@ describe("CSSVariablesCollectorPlugin.getResolvedUrl", function() {
2041 assert . strictEqual (
2142 CSSVariablesCollectorPlugin . getResolvedUrl ( {
2243 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"
2446 } ) ,
2547 "/assets/img/foo.png"
2648 ) ;
@@ -29,9 +51,20 @@ describe("CSSVariablesCollectorPlugin.getResolvedUrl", function() {
2951 assert . strictEqual (
3052 CSSVariablesCollectorPlugin . getResolvedUrl ( {
3153 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"
3356 } ) ,
3457 "http://example.com/assets/img/foo.png"
3558 ) ;
3659 } ) ;
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+ } ) ;
3770} ) ;
0 commit comments