Skip to content

Commit

Permalink
feat: update property propagation acc to API.md
Browse files Browse the repository at this point in the history
pass also docVersion, plugins, history
  • Loading branch information
JakobVogelsang committed Nov 9, 2024
1 parent df36035 commit 6693f56
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 5 deletions.
80 changes: 80 additions & 0 deletions open-scd.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,46 @@ describe('with editor plugins loaded', () => {
const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('editCount', 1);
});

it('passes property docVersion', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('docVersion', 0);
});

it('updated passed docVersion property on edit events', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

editor.dispatchEvent(
newEditEvent({
element: doc.querySelector('testdoc')!,
attributes: { name: 'someName' },
})
);
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('docVersion', 1);
});

it('passes property history', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('history');
});

it('passes property plugins', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('plugins');
});
});

describe('with menu plugins loaded', () => {
Expand Down Expand Up @@ -149,4 +189,44 @@ describe('with menu plugins loaded', () => {
const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('editCount', 1);
});

it('passes property docVersion', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('docVersion', 0);
});

it('updated passed docVersion property on edit events', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

editor.dispatchEvent(
newEditEvent({
element: doc.querySelector('testdoc')!,
attributes: { name: 'someName' },
})
);
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('docVersion', 1);
});

it('passes property history', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('history');
});

it('passes property plugins', async () => {
editor.dispatchEvent(newOpenEvent(doc, 'test.xml'));
await editor.updateComplete;

const plugin = editor.shadowRoot?.querySelector('*[docname="test.xml"]');
expect(plugin).to.have.property('plugins');
});
});
16 changes: 11 additions & 5 deletions open-scd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,14 @@ export class OpenSCD extends LitElement {
</mwc-tab-bar>
${this.editor
? staticHtml`<${unsafeStatic(this.editor)} docName="${
this.docName || nothing
this.docName
}" .doc=${this.doc} locale="${this.locale}" .docs=${
this.docs
} .editCount=${this.editCount}></${unsafeStatic(this.editor)}>`
} .editCount=${this.editCount} .docVersion=${
this.docVersion
} .history=${this.history} .plugins=${
this.plugins
}></${unsafeStatic(this.editor)}>`
: nothing}
</mwc-top-app-bar-fixed>
</mwc-drawer>
Expand Down Expand Up @@ -502,9 +506,11 @@ export class OpenSCD extends LitElement {
this.docName
}" .doc=${this.doc} locale="${this.locale}" .docs=${
this.docs
} .editCount=${this.editCount}></${unsafeStatic(
pluginTag(plugin.src)
)}>`
} .editCount=${this.editCount} .docVersion=${
this.docVersion
} .history=${this.history} .plugins=${
this.plugins
} ></${unsafeStatic(pluginTag(plugin.src))}>`
)}
</aside>`;
}
Expand Down

0 comments on commit 6693f56

Please sign in to comment.