From 469e558cae43d6a0c063170dd23e2337c0e5af26 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Mon, 10 Dec 2018 14:42:13 +0100 Subject: [PATCH] [FIX] ComponentAnalyzer: Handle sap.ui5/rootView with type string --- lib/lbt/analyzer/ComponentAnalyzer.js | 13 +++++- test/lib/lbt/analyzer/ComponentAnalyzer.js | 51 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/lib/lbt/analyzer/ComponentAnalyzer.js b/lib/lbt/analyzer/ComponentAnalyzer.js index 4abcae7ec..73bb1d248 100644 --- a/lib/lbt/analyzer/ComponentAnalyzer.js +++ b/lib/lbt/analyzer/ComponentAnalyzer.js @@ -93,9 +93,18 @@ class ComponentAnalyzer { } if ( ui5.rootView ) { + let rootView; + if ( typeof ui5.rootView === "string" ) { + rootView = { + viewName: ui5.rootView, + type: "XML" + }; + } else { + rootView = ui5.rootView; + } const module = ModuleName.fromUI5LegacyName( - ui5.rootView.viewName, - ".view." + ui5.rootView.type.toLowerCase() ); + rootView.viewName, + ".view." + rootView.type.toLowerCase() ); log.verbose("adding root view dependency ", module); info.addDependency( module ); } diff --git a/test/lib/lbt/analyzer/ComponentAnalyzer.js b/test/lib/lbt/analyzer/ComponentAnalyzer.js index 981d1b557..2400634b6 100644 --- a/test/lib/lbt/analyzer/ComponentAnalyzer.js +++ b/test/lib/lbt/analyzer/ComponentAnalyzer.js @@ -172,3 +172,54 @@ test("routing with targets with local config", (t) => { }); }); +test("rootView with object", (t) => { + const mockManifest = { + "sap.ui5": { + rootView: { + viewName: "test.view.App", + type: "JS", + async: true + } + } + }; + + const mockPool = createMockPool("test/", mockManifest); + + const mockInfo = { + deps: [], + addDependency(name) { + this.deps.push(name); + } + }; + + const subject = new ComponentAnalyzer(mockPool); + return subject.analyze({name: "test/Component.js"}, mockInfo).then( () => { + t.deepEqual(mockInfo.deps, [ + "test/view/App.view.js", + ], "dependencies should be correct"); + }); +}); + +test("rootView with string", (t) => { + const mockManifest = { + "sap.ui5": { + rootView: "test.view.App" + } + }; + + const mockPool = createMockPool("test/", mockManifest); + + const mockInfo = { + deps: [], + addDependency(name) { + this.deps.push(name); + } + }; + + const subject = new ComponentAnalyzer(mockPool); + return subject.analyze({name: "test/Component.js"}, mockInfo).then( () => { + t.deepEqual(mockInfo.deps, [ + "test/view/App.view.xml", + ], "dependencies should be correct"); + }); +});