Skip to content

Commit

Permalink
[FIX] ComponentAnalyzer: Handle sap.ui5/rootView with type string
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Dec 10, 2018
1 parent fc11cbe commit 469e558
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/lbt/analyzer/ComponentAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
51 changes: 51 additions & 0 deletions test/lib/lbt/analyzer/ComponentAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});

0 comments on commit 469e558

Please sign in to comment.