Skip to content

Commit

Permalink
chore: simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhsf committed Dec 19, 2024
1 parent f79516b commit baf00fd
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export function buildCustomElementConstructor(Ctor: ComponentConstructor): HTMLE

attributeChangedCallback(name: string, oldValue: any, newValue: any) {
if (this instanceof CustomElementConstructor) {
// W-17420330
attributeChangedCallback.call(this, name, oldValue, newValue);
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TimingParent from 'timing/parent';
import TimingParentLight from 'timing/parentLight';
import ReorderingList from 'reordering/list';
import ReorderingListLight from 'reordering/listLight';
import AttrParent from 'attr/parent';
import Details from 'x/details';

function resetTimingBuffer() {
window.timingBuffer = [];
Expand Down Expand Up @@ -425,19 +425,14 @@ describe('dispatchEvent from connectedCallback/disconnectedCallback', () => {
});

describe('attributeChangedCallback', () => {
fit('W-17420330 - only fires for registered component', async () => {
const root = createElement('attr-parent', { is: AttrParent });
it('W-17420330 - only fires for registered component', async () => {
const root = createElement('x-details', { is: Details });
document.body.appendChild(root);
await Promise.resolve();

// const elm = root.shadowRoot.firstElementChild.shadowRoot.querySelector('details');
// expect(elm.getAttribute('open')).toBe(null);

/** `.shadowRoot.querySelector()` */
await Promise.resolve(setTimeout);
const srqs = (elm, sel) => elm.shadowRoot.querySelector(sel);
const direct = srqs(srqs(root, 'attr-details'), 'details');
expect(direct.getAttribute('open')).toBe(null);
const indirect = srqs(srqs(root, 'attr-indirect'), 'details');
expect(indirect.getAttribute('open')).toBe(null);
const details = root.shadowRoot.querySelector('details');
const cb = Details.CustomElementConstructor.prototype.attributeChangedCallback;
cb.call(details, 'open', '', 'open');
expect(details.getAttribute('open')).toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<details>
<summary>An Ode to Toads</summary>
<p>
Violets are red,<br>
Roses are blue,<br>
Toads are cool!
</p>
</details>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LightningElement, api } from 'lwc';

export default class Details extends LightningElement {
@api open;
}

0 comments on commit baf00fd

Please sign in to comment.