Newer
Older
import {Button} from './button';
import {newSpecPage} from '@stencil/core/testing';
it('should render correctly without attributes', async () => {
const page = await newSpecPage({
components: [Button],
});
expect(page.root).toEqualHtml(`
<hy-button>
<button type="submit" class="hy-button primary enabled size-normal">
Hello tests!
</span>
</button>
</hy-button>
`);
});
it('should have classname matching the variant', async () => {
const page = await newSpecPage({
components: [Button],
html: `<hy-button variant="secondary">Hello icons!<hy-button>`,
const button = page.doc.querySelector('button.secondary');
it('should have classname matching the state', async () => {
html: `<hy-button disabled>I am disabled!<hy-button>`,
const button = page.doc.querySelector('button');
expect(button).toHaveAttribute('disabled');
it('should display an arrow element', async () => {
const page = await newSpecPage({
components: [Button],
html: `<hy-button
icon="hy-icon-arrow-left"
const icon = page.doc.querySelector('span.hy-button__icon');
expect(icon).toHaveClass('hy-button__icon');
const page = await newSpecPage({
components: [Button],
html: `<hy-button
variant="secondary"
icon="hy-icon-arrow-left"
icon-right="hy-icon-arrow-right">Hello icons!<hy-button>`,
const icons = page.doc.querySelectorAll('span.hy-button__icon');