Skip to content

Commit

Permalink
Add "with custom registry" tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Orvell committed Jun 7, 2024
1 parent f319740 commit d66b556
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,51 @@ describe('ShadowRoot', () => {
});
});

describe('createElementNS', () => {
it('should create a regular element', () => {
const registry = new CustomElementRegistry();
const shadowRoot = getShadowRoot(registry);

const $el = shadowRoot.createElementNS(
'http://www.w3.org/1999/xhtml',
'div'
);

expect($el).to.not.be.undefined;
expect($el).to.be.instanceof(HTMLDivElement);
});

it(`shouldn't upgrade an element defined in the global registry`, () => {
const {tagName, CustomElementClass} = getTestElement();
customElements.define(tagName, CustomElementClass);
const registry = new CustomElementRegistry();
const shadowRoot = getShadowRoot(registry);

const $el = shadowRoot.createElementNS(
'http://www.w3.org/1999/xhtml',
tagName
);

expect($el).to.not.be.undefined;
expect($el).to.not.be.instanceof(CustomElementClass);
});

it(`should upgrade an element defined in the custom registry`, () => {
const {tagName, CustomElementClass} = getTestElement();
const registry = new CustomElementRegistry();
registry.define(tagName, CustomElementClass);
const shadowRoot = getShadowRoot(registry);

const $el = shadowRoot.createElementNS(
'http://www.w3.org/1999/xhtml',
tagName
);

expect($el).to.not.be.undefined;
expect($el).to.be.instanceof(CustomElementClass);
});
});

describe('innerHTML', () => {
it(`shouldn't upgrade a defined custom element in the global registry`, () => {
const {tagName, CustomElementClass} = getTestElement();
Expand Down

0 comments on commit d66b556

Please sign in to comment.