123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- /**
- * @license
- * Copyright 2021 Google LLC
- * SPDX-License-Identifier: BSD-3-Clause
- */
- 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>`)) as MyElement;
- 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>
- `
- );
- });
- test('styling applied', async () => {
- const el = (await fixture(html`<my-element></my-element>`)) as MyElement;
- await el.updateComplete;
- assert.equal(getComputedStyle(el).paddingTop, '16px');
- });
- });
|