-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add internal has-input-value-changed event (#209)
- Loading branch information
1 parent
bbb8c02
commit af68970
Showing
3 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>vaadin-time-picker events tests</title> | ||
<script src='../../web-component-tester/browser.js'></script> | ||
<script src='../../webcomponentsjs/webcomponents-lite.js'></script> | ||
<link rel="import" href="../src/vaadin-time-picker.html"> | ||
<link rel="import" href="../../test-fixture/test-fixture.html"> | ||
</head> | ||
|
||
<body> | ||
<test-fixture id="time-picker"> | ||
<template> | ||
<vaadin-time-picker></vaadin-time-picker> | ||
</template> | ||
</test-fixture> | ||
<script> | ||
describe('events', () => { | ||
let timePicker, input; | ||
|
||
describe('has-input-value-changed event', () => { | ||
beforeEach(async() => { | ||
timePicker = fixture('time-picker'); | ||
input = timePicker.__inputElement; | ||
}); | ||
|
||
it('should fire the event on input value presence change', async() => { | ||
const hasInputValueChangedSpy = sinon.spy(); | ||
timePicker.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = '13:00'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
expect(hasInputValueChangedSpy.calledOnce).to.be.true; | ||
|
||
hasInputValueChangedSpy.reset(); | ||
input.value = ''; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
expect(hasInputValueChangedSpy.calledOnce).to.be.true; | ||
}); | ||
|
||
it('should not fire the event on input if input value presence has not changed', async() => { | ||
const hasInputValueChangedSpy = sinon.spy(); | ||
timePicker.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = '13:00'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
hasInputValueChangedSpy.reset(); | ||
|
||
input.value = '13:58'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
expect(hasInputValueChangedSpy.called).to.be.false; | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</body> |
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