diff --git a/src/zeroline/function-editor.ts b/src/zeroline/function-editor.ts
index 980f0a688..2ed81f255 100644
--- a/src/zeroline/function-editor.ts
+++ b/src/zeroline/function-editor.ts
@@ -8,6 +8,8 @@ import {
} from 'lit-element';
import '../action-pane.js';
+import './subfunction-editor.js';
+import { getChildElementsByTagName } from '../foundation.js';
/** Pane rendering `Function` element with its children */
@customElement('function-editor')
@@ -24,12 +26,21 @@ export class FunctionEditor extends LitElement {
return `${name}${desc ? ` - ${desc}` : ''}${type ? ` (${type})` : ''}`;
}
+ renderSubFunctions(): TemplateResult {
+ const subfunctions = getChildElementsByTagName(this.element, 'SubFunction');
+ return html` ${subfunctions.map(
+ subFunction =>
+ html``
+ )}`;
+ }
+
render(): TemplateResult {
return html``;
+ >${this.renderSubFunctions()}`;
}
}
diff --git a/src/zeroline/subfunction-editor.ts b/src/zeroline/subfunction-editor.ts
new file mode 100644
index 000000000..6e12ef760
--- /dev/null
+++ b/src/zeroline/subfunction-editor.ts
@@ -0,0 +1,42 @@
+import {
+ html,
+ LitElement,
+ TemplateResult,
+ property,
+ customElement,
+ state,
+} from 'lit-element';
+
+import '../action-pane.js';
+import './subfunction-editor.js';
+import { getChildElementsByTagName } from '../foundation.js';
+
+/** Pane rendering `SubFunction` element with its children */
+@customElement('subfunction-editor')
+export class SubFunctionEditor extends LitElement {
+ /** The edited `SubFunction` element */
+ @property({ attribute: false })
+ element!: Element;
+ @state()
+ get header(): string {
+ const name = this.element.getAttribute('name');
+ const desc = this.element.getAttribute('desc');
+ const type = this.element.getAttribute('type');
+
+ return `${name}${desc ? ` - ${desc}` : ''}${type ? ` (${type})` : ''}`;
+ }
+
+ renderSubFunctions(): TemplateResult {
+ const subfunctions = getChildElementsByTagName(this.element, 'SubFunction');
+ return html` ${subfunctions.map(
+ subFunction =>
+ html``
+ )}`;
+ }
+
+ render(): TemplateResult {
+ return html`${this.renderSubFunctions()}`;
+ }
+}
diff --git a/test/testfiles/zeroline/functions.scd b/test/testfiles/zeroline/functions.scd
index 51be8e942..5e87b5f15 100644
--- a/test/testfiles/zeroline/functions.scd
+++ b/test/testfiles/zeroline/functions.scd
@@ -7,12 +7,16 @@
-
+
+
+
110.0
-
-
+
+
+
+
diff --git a/test/unit/zeroline/__snapshots__/function-editor.test.snap.js b/test/unit/zeroline/__snapshots__/function-editor.test.snap.js
new file mode 100644
index 000000000..f4131b1c6
--- /dev/null
+++ b/test/unit/zeroline/__snapshots__/function-editor.test.snap.js
@@ -0,0 +1,31 @@
+/* @web/test-runner snapshot v1 */
+export const snapshots = {};
+
+snapshots["web component rendering Function element with complete attribute set and existing children looks like the latest snapshot"] =
+`
+
+
+
+`;
+/* end snapshot web component rendering Function element with complete attribute set and existing children looks like the latest snapshot */
+
+snapshots["web component rendering Function element with missing desc and type attribute looks like the latest snapshot"] =
+`
+
+
+
+`;
+/* end snapshot web component rendering Function element with missing desc and type attribute looks like the latest snapshot */
+
diff --git a/test/unit/zeroline/__snapshots__/subfunction-editor.test.snap.js b/test/unit/zeroline/__snapshots__/subfunction-editor.test.snap.js
new file mode 100644
index 000000000..8f5f8d987
--- /dev/null
+++ b/test/unit/zeroline/__snapshots__/subfunction-editor.test.snap.js
@@ -0,0 +1,27 @@
+/* @web/test-runner snapshot v1 */
+export const snapshots = {};
+
+snapshots["web component rendering SubFunction element with complete attribute set and existing children looks like the latest snapshot"] =
+`
+
+
+
+`;
+/* end snapshot web component rendering SubFunction element with complete attribute set and existing children looks like the latest snapshot */
+
+snapshots["web component rendering SubFunction element with missing desc and type attribute looks like the latest snapshot"] =
+`
+
+`;
+/* end snapshot web component rendering SubFunction element with missing desc and type attribute looks like the latest snapshot */
+
diff --git a/test/unit/zeroline/function-editor.test.ts b/test/unit/zeroline/function-editor.test.ts
new file mode 100644
index 000000000..9536ff500
--- /dev/null
+++ b/test/unit/zeroline/function-editor.test.ts
@@ -0,0 +1,47 @@
+import { fixture, html, expect } from '@open-wc/testing';
+
+import '../../../src/zeroline/function-editor.js';
+import { FunctionEditor } from '../../../src/zeroline/function-editor.js';
+
+describe('web component rendering Function element', () => {
+ let element: FunctionEditor;
+ let doc: XMLDocument;
+
+ beforeEach(async () => {
+ doc = await fetch('/test/testfiles/zeroline/functions.scd')
+ .then(response => response.text())
+ .then(str => new DOMParser().parseFromString(str, 'application/xml'));
+ });
+
+ describe('with complete attribute set and existing children', () => {
+ beforeEach(async () => {
+ element = (
+ await fixture(
+ html``
+ )
+ );
+ });
+
+ it('looks like the latest snapshot', async () => {
+ await expect(element).shadowDom.to.equalSnapshot();
+ });
+ });
+
+ describe('with missing desc and type attribute', () => {
+ beforeEach(async () => {
+ element = (
+ await fixture(
+ html``
+ )
+ );
+ });
+
+ it('looks like the latest snapshot', async () => {
+ await expect(element).shadowDom.to.equalSnapshot();
+ });
+ });
+});
diff --git a/test/unit/zeroline/subfunction-editor.test.ts b/test/unit/zeroline/subfunction-editor.test.ts
new file mode 100644
index 000000000..97740500a
--- /dev/null
+++ b/test/unit/zeroline/subfunction-editor.test.ts
@@ -0,0 +1,47 @@
+import { fixture, html, expect } from '@open-wc/testing';
+
+import '../../../src/zeroline/subfunction-editor.js';
+import { SubFunctionEditor } from '../../../src/zeroline/subfunction-editor.js';
+
+describe('web component rendering SubFunction element', () => {
+ let element: SubFunctionEditor;
+ let doc: XMLDocument;
+
+ beforeEach(async () => {
+ doc = await fetch('/test/testfiles/zeroline/functions.scd')
+ .then(response => response.text())
+ .then(str => new DOMParser().parseFromString(str, 'application/xml'));
+ });
+
+ describe('with complete attribute set and existing children', () => {
+ beforeEach(async () => {
+ element = (
+ await fixture(
+ html``
+ )
+ );
+ });
+
+ it('looks like the latest snapshot', async () => {
+ await expect(element).shadowDom.to.equalSnapshot();
+ });
+ });
+
+ describe('with missing desc and type attribute', () => {
+ beforeEach(async () => {
+ element = (
+ await fixture(
+ html``
+ )
+ );
+ });
+
+ it('looks like the latest snapshot', async () => {
+ await expect(element).shadowDom.to.equalSnapshot();
+ });
+ });
+});