Created
June 7, 2019 17:20
-
-
Save Tallyb/969d850e05c9f301c30c34ef9f2ccf23 to your computer and use it in GitHub Desktop.
complex prop testing
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
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