diff --git a/lib/lbt/analyzer/XMLTemplateAnalyzer.js b/lib/lbt/analyzer/XMLTemplateAnalyzer.js index faa819b1f..5a3aa8e89 100644 --- a/lib/lbt/analyzer/XMLTemplateAnalyzer.js +++ b/lib/lbt/analyzer/XMLTemplateAnalyzer.js @@ -162,6 +162,12 @@ class XMLTemplateAnalyzer { return; } + if ( !result ) { + // Handle empty xml views/fragments + reject(new Error("Invalid empty XML document: " + info.name)); + return; + } + // console.log(result); // clear(); if ( isFragment ) { diff --git a/test/lib/lbt/analyzer/XMLTemplateAnalyzer.js b/test/lib/lbt/analyzer/XMLTemplateAnalyzer.js index 40069981b..1b8485a84 100644 --- a/test/lib/lbt/analyzer/XMLTemplateAnalyzer.js +++ b/test/lib/lbt/analyzer/XMLTemplateAnalyzer.js @@ -3,6 +3,10 @@ const XMLTemplateAnalyzer = require("../../../../lib/lbt/analyzer/XMLTemplateAna const ModuleInfo = require("../../../../lib/lbt/resources/ModuleInfo"); const sinon = require("sinon"); +const fakeMockPool = { + findResource: () => Promise.resolve() +}; + test("integration: Analysis of an xml view", async (t) => { const xml = ` @@ -13,15 +17,10 @@ test("integration: Analysis of an xml view", async (t) => { `; - const mockPool = {async findResource(name) { - return { - buffer: () => name.endsWith(".xml") ? JSON.stringify(xml): "test" - }; - }}; const moduleInfo = new ModuleInfo(); - const analyzer = new XMLTemplateAnalyzer(mockPool); + const analyzer = new XMLTemplateAnalyzer(fakeMockPool); await analyzer.analyzeView(xml, moduleInfo); t.deepEqual(moduleInfo.dependencies, [ @@ -39,15 +38,10 @@ test("integration: Analysis of an xml view with data binding in properties", asy controllerName="myController"> `; - const mockPool = {async findResource(name) { - return { - buffer: () => name.endsWith(".xml") ? JSON.stringify(xml): "test" - }; - }}; const moduleInfo = new ModuleInfo(); - const analyzer = new XMLTemplateAnalyzer(mockPool); + const analyzer = new XMLTemplateAnalyzer(fakeMockPool); await analyzer.analyzeView(xml, moduleInfo); t.deepEqual(moduleInfo.dependencies, [ @@ -70,15 +64,10 @@ test("integration: Analysis of an xml view with core:require", async (t) => {