Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit 8ea52b2

Browse files
Adrián González Rusadrigzr
authored andcommitted
test(coverage): add more tests
1 parent 5a7a743 commit 8ea52b2

3 files changed

Lines changed: 56 additions & 5 deletions

File tree

tests/integration/index-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,18 @@ module('Integration | index', (hooks) => {
201201

202202
await render(hbs`<my-render data-id="bar"/>`);
203203
});
204+
205+
test('it can render same custom element multiple times', async(assert) => {
206+
await render(hbs`<int-my-content data-id="foo">foo</int-my-content>`);
207+
208+
const foo = find('[data-id="foo"]');
209+
210+
foo.textContent = 'bar';
211+
212+
await settled();
213+
214+
const inner = shadowFind('int-my-content', '[data-id="foo"]');
215+
216+
assert.equal(inner.textContent.trim(), 'bar');
217+
});
204218
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { module, test } from 'qunit';
2+
import { defineCustomElements } from 'ember-cli-web-components';
3+
4+
module('Integration | no-component', (hooks) => {
5+
hooks.beforeEach(() => {
6+
defineCustomElements({
7+
'fake-component': {
8+
name: 'fake-component'
9+
}
10+
});
11+
});
12+
13+
test('it defines custom component', (assert) => {
14+
const customElement = customElements.get('fake-component');
15+
16+
assert.ok(customElement);
17+
});
18+
19+
test('custom element can be created', async(assert) => {
20+
const element = document.createElement('fake-component');
21+
22+
const rootElement = document.querySelector('#ember-testing');
23+
24+
rootElement.appendChild(element);
25+
26+
assert.ok(element.isConnected);
27+
});
28+
});

tests/integration/no-instance-test.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
11
import { module, test } from 'qunit';
22
import { defineCustomElements } from 'ember-cli-web-components';
3+
import Component from '@ember/component';
34

4-
module('Integration | no-component', (hooks) => {
5+
module('Integration | no-instance', (hooks) => {
56
hooks.beforeEach(() => {
7+
define('dummy/components/no-instance', ['exports'], (exports) => {
8+
exports.default = Component.extend();
9+
});
10+
611
defineCustomElements({
7-
'fake-component': {
8-
name: 'fake-component'
12+
'no-instance': {
13+
name: 'no-instance'
914
}
1015
});
1116
});
1217

18+
hooks.afterEach(() => {
19+
delete require('dummy/components/no-instance');
20+
});
21+
1322
test('it defines custom component', (assert) => {
14-
const customElement = customElements.get('fake-component');
23+
const customElement = customElements.get('no-instance');
1524

1625
assert.ok(customElement);
1726
});
1827

1928
test('custom element can be created', async(assert) => {
20-
const element = document.createElement('fake-component');
29+
const element = document.createElement('no-instance');
2130

2231
const rootElement = document.querySelector('#ember-testing');
2332

0 commit comments

Comments
 (0)