forked from lit/lit-element-starter-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arthur Evans
committed
Apr 13, 2020
1 parent
568b328
commit 3de99b3
Showing
2 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
/node_modules/ | ||
/lib/ | ||
/test/ | ||
|
||
# top level source | ||
my-element.js | ||
my-element.js.map | ||
my-element.d.ts | ||
my-element.d.ts.map | ||
# only generated for size check | ||
my-element.bundled.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {MyElement} from '../my-element.js'; | ||
import {fixture, html} from '@open-wc/testing'; | ||
|
||
const assert = chai.assert; | ||
|
||
suite('my-element', () => { | ||
test('is defined', () => { | ||
const el = document.createElement('my-element'); | ||
assert.instanceOf(el, MyElement); | ||
}); | ||
|
||
test('renders with default values', async () => { | ||
const el = await fixture(html`<my-element></my-element>`); | ||
assert.shadowDom.equal( | ||
el, | ||
` | ||
<h1>Hello, World!</h1> | ||
<button part="button">Click Count: 0</button> | ||
<slot></slot> | ||
` | ||
); | ||
}); | ||
|
||
test('renders with a set name', async () => { | ||
const el = await fixture(html`<my-element name="Test"></my-element>`); | ||
assert.shadowDom.equal( | ||
el, | ||
` | ||
<h1>Hello, Test!</h1> | ||
<button part="button">Click Count: 0</button> | ||
<slot></slot> | ||
` | ||
); | ||
}); | ||
|
||
test('handles a click', async () => { | ||
const el = await fixture(html`<my-element></my-element>`); | ||
const button = el.shadowRoot.querySelector('button'); | ||
button.click(); | ||
await el.updateComplete; | ||
assert.shadowDom.equal( | ||
el, | ||
` | ||
<h1>Hello, World!</h1> | ||
<button part="button">Click Count: 1</button> | ||
<slot></slot> | ||
` | ||
); | ||
}); | ||
}); |