Skip to content

Commit 0741024

Browse files
add unit test
1 parent 9bd2bab commit 0741024

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/runtime/initialize-component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ export const initializeComponent = async (
9898
* ```html
9999
* <script type="module">
100100
* import { MyComponent } from 'my-stencil-component-library';
101-
* console.log(1, MyComponent, customElements);
102101
* customElements.define('my-other-component', MyComponent);
103102
* </script>
104103
* ```

test/wdio/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ declare global {
1212
const testRequiresManualSetup =
1313
window.__wdioSpec__.includes('custom-elements-output-tag-class-different') ||
1414
window.__wdioSpec__.includes('custom-elements-delegates-focus') ||
15-
window.__wdioSpec__.includes('custom-elements-output');
15+
window.__wdioSpec__.includes('custom-elements-output') ||
16+
window.__wdioSpec__.endsWith('custom-tag-name.test.tsx');
1617

1718
/**
1819
* setup all components defined in tests except for those where we want ot manually setup
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { h } from '@stencil/core';
2+
import { render } from '@wdio/browser-runner/stencil';
3+
4+
import { WatchNativeAttributes } from '../test-components/watch-native-attributes.js';
5+
6+
describe('watch native attributes', () => {
7+
beforeEach(() => {
8+
customElements.define('some-custom-element', WatchNativeAttributes);
9+
render({
10+
template: () => <some-custom-element aria-label="myStartingLabel"></some-custom-element>,
11+
});
12+
});
13+
14+
it('triggers the callback for the watched attribute', async () => {
15+
const $cmp = $('some-custom-element');
16+
await $cmp.waitForExist();
17+
18+
await expect($cmp).toHaveText('Label: myStartingLabel\nCallback triggered: false');
19+
20+
const cmp = document.querySelector('some-custom-element');
21+
cmp.setAttribute('aria-label', 'myNewLabel');
22+
23+
await expect($cmp).toHaveText('Label: myNewLabel\nCallback triggered: true');
24+
});
25+
});

0 commit comments

Comments
 (0)