Skip to content

Instantly share code, notes, and snippets.

@Tallyb
Created June 7, 2019 17:20
Show Gist options
  • Save Tallyb/969d850e05c9f301c30c34ef9f2ccf23 to your computer and use it in GitHub Desktop.
Save Tallyb/969d850e05c9f301c30c34ef9f2ccf23 to your computer and use it in GitHub Desktop.
complex prop testing
import { newSpecPage } from '@stencil/core/testing';
import { MyComplexPropComponent } from './complex-prop';
describe('complex prop', () => {
it ('should change to upper case', () => {
let cmp = new MyComplexPropComponent();
let res = cmp.toUpper(['aaa', 'bbb', 'ccc']);
expect(res).toEqual(['AAA', 'BBB', 'CCC']);
});
it('should render', async () => {
const page = await newSpecPage({
components: [MyComplexPropComponent],
html: `
<my-complex-prop>
</my-complex-prop>
`
});
page.rootInstance.values = ['aaa', 'bbb', 'ccc'];
await page.waitForChanges();
expect(page.root).toMatchSnapshot();
});
it('should render with data', async () => {
const page = await newSpecPage({
components: [MyComplexPropComponent],
html: '<div></div>'
});
let cmp = page.doc.createElement('my-complex-prop');
(cmp as any).values = ['aaa', 'bbb', 'ccc'];
page.root.appendChild(cmp);
await page.waitForChanges();
expect(page.root).toMatchSnapshot();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment