Skip to content

Instantly share code, notes, and snippets.

@StefanNieuwenhuis
Last active April 12, 2019 14:33
Show Gist options
  • Save StefanNieuwenhuis/ae3a52388de2902aa9f1ca57bf1ae35e to your computer and use it in GitHub Desktop.
Save StefanNieuwenhuis/ae3a52388de2902aa9f1ca57bf1ae35e to your computer and use it in GitHub Desktop.
import { newE2EPage } from '@stencil/core/testing';
describe('my-component', () => {
let page, component, element;
beforeEach(async () => {
page = await newE2EPage();
await page.setContent('<my-component></my-component>');
component = await page.find('my-component');
element = await page.find('my-component >>> div');
});
it('renders', async () => {
expect(component).toHaveClass('hydrated');
});
it('renders a div, decorated with a class, called overlay', async () => {
expect(element).toHaveClass('overlay');
});
describe('open', () => {
it('should add the is-visible class to the overlay', async () => {
component.setProperty('open', true);
await page.waitForChanges();
expect(element).toHaveClass('is-visible');
});
it('should add the is-transparent class to the overlay, when the property is set', async () => {
component.setProperty('open', true);
component.setProperty('transparent', true);
await page.waitForChanges();
expect(element).toHaveClasses(['is-visible', 'is-transparent']);
});
});
describe('close', () => {
it('should remove the is-visible class from the overlay', async () => {
component.setProperty('open', true);
await page.waitForChanges();
expect(element).toHaveClass('is-visible');
component.setProperty('open', false);
await page.waitForChanges();
expect(element).not.toHaveClass('is-visible');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment