Created
June 10, 2019 16:17
-
-
Save Tallyb/46f4055b4423e7d98a7fd86397399ff9 to your computer and use it in GitHub Desktop.
Input spec
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 {MyInput} from './input'; | |
describe('MyInput', () => { | |
it('Should emit thisHappened when input entered', async() => { | |
const TEST_VALUE = 'Test Value' | |
const page = await newSpecPage({ | |
components: [ MyInput ], | |
html: `<my-input ></my-input>` | |
}); | |
let inputSpy = jest.fn(); | |
page.doc.addEventListener('thisHappened', inputSpy); | |
let inputField = page.root.shadowRoot.querySelector('input'); | |
inputField.value = TEST_VALUE; | |
await inputField.dispatchEvent(new Event('input')); | |
await page.waitForChanges(); | |
expect(inputSpy).toHaveBeenCalled(); | |
let ev = inputSpy.mock.calls[inputSpy.mock.calls.length - 1][0].detail; | |
expect(ev).toBe(TEST_VALUE); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment