@@ -74,12 +74,12 @@ class FixtureHelper {
7474}
7575
7676describe ( "ui5 build" , ( ) => {
77- test ( "ui5-tooling-transpile-middleware " , async ( { assert} ) => {
77+ test ( "ui5-tooling-transpile" , async ( { assert} ) => {
7878 const fixtureHelper = new FixtureHelper ( "application.a.ts" ) ;
7979 await fixtureHelper . init ( ) ;
8080 process . env . UI5_DATA_DIR = `${ fixtureHelper . dotUi5Path } ` ;
8181 process . chdir ( fixtureHelper . tmpPath ) ;
82- const ui5YamlName = "ui5-tooling-transpile-middleware .yaml" ;
82+ const ui5YamlName = "ui5-tooling-transpile.yaml" ;
8383
8484 // #1 Build
8585 await fixtureHelper . build ( assert , ui5YamlName ) ;
@@ -108,8 +108,8 @@ describe("ui5 build", () => {
108108 assert . ok ( newComponentPreload . includes ( "second:\"test_2\"" ) , "Component-preload.js should contain the updated content from the modified source file" ) ;
109109 } ) ;
110110
111- test . only ( "ui5-task-zipper" , async ( { assert} ) => {
112- const fixtureHelper = new FixtureHelper ( "application.a.ts " ) ;
111+ test ( "ui5-task-zipper" , async ( { assert} ) => {
112+ const fixtureHelper = new FixtureHelper ( "application.a" ) ;
113113 await fixtureHelper . init ( ) ;
114114 process . env . UI5_DATA_DIR = `${ fixtureHelper . dotUi5Path } ` ;
115115 process . chdir ( fixtureHelper . tmpPath ) ;
@@ -129,14 +129,14 @@ describe("ui5 build", () => {
129129 assert . ok ( zipEntries . length > 0 , "The zip file should contain entries" ) ;
130130
131131 // Check that the zip file contains the expected source file
132- const testControllerEntry = zipEntries . find ( entry => entry . entryName === "controller/Test.controller.ts " ) ;
132+ const testControllerEntry = zipEntries . find ( entry => entry . entryName === "controller/Test.controller.js " ) ;
133133 assert . ok ( testControllerEntry , "The zip file should contain the expected source file" ) ;
134134
135135 // --------------------------------------------------------------------------------------------
136136
137137 // Delete a source file
138138 await fixtureHelper . prepareForNextRun ( ) ;
139- await fs . rm ( path . resolve ( fixtureHelper . tmpPath , "webapp/controller/Test.controller.ts " ) ) ;
139+ await fs . rm ( path . resolve ( fixtureHelper . tmpPath , "webapp/controller/Test.controller.js " ) ) ;
140140
141141 // #2 Build
142142 await fixtureHelper . build ( assert , ui5YamlName ) ;
@@ -151,7 +151,46 @@ describe("ui5 build", () => {
151151 assert . ok ( zipEntries2 . length > 0 , "The zip file should contain entries after the second build" ) ;
152152
153153 // Check that the zip file does NOT contain the expected source file anymore
154- const deletedTestControllerEntry = zipEntries2 . find ( entry => entry . entryName === "controller/Test.controller.ts " ) ;
154+ const deletedTestControllerEntry = zipEntries2 . find ( entry => entry . entryName === "controller/Test.controller.js " ) ;
155155 assert . ok ( ! deletedTestControllerEntry , "The zip file should NOT contain the deleted source file" ) ;
156156 } ) ;
157+
158+ test ( "ui5-tooling-modules" , async ( { assert} ) => {
159+ const fixtureHelper = new FixtureHelper ( "application.a" ) ;
160+ await fixtureHelper . init ( ) ;
161+ process . env . UI5_DATA_DIR = `${ fixtureHelper . dotUi5Path } ` ;
162+ process . chdir ( fixtureHelper . tmpPath ) ;
163+ const ui5YamlName = "ui5-tooling-modules.yaml" ;
164+
165+ // #1 Build
166+ await fixtureHelper . build ( assert , ui5YamlName ) ;
167+
168+ // Test: the dist contains the expected preload with the correct content
169+ const componentPreload = await fs . readFile ( path . resolve ( fixtureHelper . distPath , "Component-preload.js" ) , "utf-8" ) ;
170+ assert . ok ( componentPreload . includes ( "sap.ui.predefine(\"application/a/controller/Test.controller\", [\"application/a/thirdparty/chart.js\"]" ) , "Component-preload.js should contain the 'Test' controller and its dependency" ) ;
171+
172+
173+ // --------------------------------------------------------------------------------------------
174+
175+ // Add a new source file with another third party import
176+ await fixtureHelper . prepareForNextRun ( ) ;
177+ const newControllerPath = path . resolve ( fixtureHelper . tmpPath , "webapp/controller/New.controller.js" ) ;
178+ const newControllerContent =
179+ `sap.ui.define(["chart.js"], (chartJS) => {
180+ return Controller.extend("application.a.controller.New",{
181+ onInit() {
182+ console.log(chartJS);
183+ }
184+ });
185+ });` ;
186+ await fs . writeFile ( newControllerPath , newControllerContent , "utf-8" ) ;
187+
188+ // #2 Build
189+ await fixtureHelper . build ( assert , ui5YamlName ) ;
190+
191+ // Test: the dist contains the new controller and the new import
192+ const newComponentPreload = await fs . readFile ( path . resolve ( fixtureHelper . distPath , "Component-preload.js" ) , "utf-8" ) ;
193+ assert . ok ( newComponentPreload . includes ( "sap.ui.predefine(\"application/a/controller/Test.controller\", [\"application/a/thirdparty/chart.js\"]" ) , "Component-preload.js should contain the 'Test' controller and its dependency" ) ;
194+ assert . ok ( newComponentPreload . includes ( "sap.ui.predefine(\"application/a/controller/New.controller\", [\"application/a/thirdparty/chart.js\"]" ) , "Component-preload.js should contain the 'New' controller and its dependency" ) ;
195+ } ) ;
157196} ) ;
0 commit comments