-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(input): add support for value change and keyboard events
- Loading branch information
1 parent
d8b307f
commit 929e5a2
Showing
8 changed files
with
89 additions
and
1,153 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export interface InputChangeEventDetail { | ||
value: string | undefined | null; | ||
|
||
} | ||
|
||
export type TextFieldTypes = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'url' | 'time'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { newE2EPage } from '@stencil/core/testing'; | ||
describe(`Input`, () => { | ||
|
||
it(`Propagates wcsChange event when a key stroke occurs on the native input`, async () => { | ||
// Given | ||
const page = await newE2EPage({ | ||
html: ` | ||
<wcs-input /> | ||
` | ||
}); | ||
const select = await page.find('wcs-input'); | ||
const input_wrapper = await page.find('wcs-input >>> input'); | ||
const changeSpy = await select.spyOnEvent('wcsChange'); | ||
|
||
// When | ||
await input_wrapper.press('A'); | ||
await page.waitForChanges(); | ||
|
||
// Then | ||
expect(changeSpy).toHaveReceivedEventTimes(1); | ||
expect(changeSpy).toHaveReceivedEventDetail({ value: 'A' }); | ||
}); | ||
|
||
it(`Propagates wcsInput event when a key stroke occurs on the native input`, async () => { | ||
// Given | ||
const page = await newE2EPage({ | ||
html: ` | ||
<wcs-input /> | ||
` | ||
}); | ||
const select = await page.find('wcs-input'); | ||
const input_wrapper = await page.find('wcs-input >>> input'); | ||
const changeSpy = await select.spyOnEvent('wcsInput'); | ||
|
||
// When | ||
await input_wrapper.press('A'); | ||
await page.waitForChanges(); | ||
|
||
// Then | ||
expect(changeSpy).toHaveReceivedEventTimes(1); | ||
console.dir(changeSpy.firstEvent); // TODO: fix the test (Quantum behaviour for now...) | ||
expect(changeSpy).toHaveReceivedEventDetail({ data: 'A' }); | ||
}); | ||
}); |
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
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
Oops, something went wrong.