From 723c18bd6420cd2478da4420b826a7e9b508460e Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 15 Nov 2024 16:11:15 -0700 Subject: [PATCH] Move load from XML call for easier testing --- api/js/etemplate/Et2Template/Et2Template.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/Et2Template/Et2Template.ts b/api/js/etemplate/Et2Template/Et2Template.ts index 470593cb18..d26070cc5f 100644 --- a/api/js/etemplate/Et2Template/Et2Template.ts +++ b/api/js/etemplate/Et2Template/Et2Template.ts @@ -366,7 +366,7 @@ export class Et2Template extends Et2Widget(LitElement) // Ask the server for the template if(!xml) { - let templates = await et2_loadXMLFromURL(this.getUrl(), null, this, this.loadFailed); + let templates = await this.loadFromFile(this.getUrl()); // Scan the file for templates and store them let fallback; @@ -393,6 +393,19 @@ export class Et2Template extends Et2Widget(LitElement) return xml; } + /** + * Load the xml from the given file + * + * Broken out here so it can be stubbed for testing + * + * @param path + * @returns {Promise} + * @protected + */ + protected loadFromFile(path) + { + return et2_loadXMLFromURL(path, null, this, this.loadFailed); + } /** * The template has been loaded, wait for child widgets to be complete. *