-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07b45b2
commit 70cb3e9
Showing
10 changed files
with
425 additions
and
3 deletions.
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
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,61 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>vaadin-email-field events tests</title> | ||
|
||
<script src="../../web-component-tester/browser.js"></script> | ||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<link rel="import" href="../vaadin-email-field.html"> | ||
<link rel="import" href="helpers.html"> | ||
<link rel="import" href="../../test-fixture/test-fixture.html"> | ||
</head> | ||
|
||
<body> | ||
<test-fixture id="email-field"> | ||
<template> | ||
<vaadin-email-field></vaadin-email-field> | ||
</template> | ||
</test-fixture> | ||
<script> | ||
describe('events', () => { | ||
let emailField, input; | ||
|
||
describe('has-input-value-changed event', () => { | ||
beforeEach(async() => { | ||
emailField = fixture('email-field'); | ||
input = emailField.inputElement; | ||
}); | ||
|
||
it('should fire the event on input value presence change', async() => { | ||
const hasInputValueChangedSpy = sinon.spy(); | ||
emailField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = 'foo'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
expect(hasInputValueChangedSpy.calledOnce).to.be.true; | ||
|
||
hasInputValueChangedSpy.reset(); | ||
input.value = ''; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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(); | ||
emailField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = 'foo'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
hasInputValueChangedSpy.reset(); | ||
|
||
input.value = 'foobar'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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
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,61 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>vaadin-integer-field events tests</title> | ||
|
||
<script src="../../web-component-tester/browser.js"></script> | ||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<link rel="import" href="../vaadin-integer-field.html"> | ||
<link rel="import" href="helpers.html"> | ||
<link rel="import" href="../../test-fixture/test-fixture.html"> | ||
</head> | ||
|
||
<body> | ||
<test-fixture id="integer-field"> | ||
<template> | ||
<vaadin-integer-field></vaadin-integer-field> | ||
</template> | ||
</test-fixture> | ||
<script> | ||
describe('events', () => { | ||
let integerField, input; | ||
|
||
describe('has-input-value-changed event', () => { | ||
beforeEach(async() => { | ||
integerField = fixture('integer-field'); | ||
input = integerField.inputElement; | ||
}); | ||
|
||
it('should fire the event on input value presence change', async() => { | ||
const hasInputValueChangedSpy = sinon.spy(); | ||
integerField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = '5'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
expect(hasInputValueChangedSpy.calledOnce).to.be.true; | ||
|
||
hasInputValueChangedSpy.reset(); | ||
input.value = ''; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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(); | ||
integerField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = '5'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
hasInputValueChangedSpy.reset(); | ||
|
||
input.value = '56'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>vaadin-number-field events tests</title> | ||
|
||
<script src="../../web-component-tester/browser.js"></script> | ||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<link rel="import" href="../vaadin-number-field.html"> | ||
<link rel="import" href="helpers.html"> | ||
<link rel="import" href="../../test-fixture/test-fixture.html"> | ||
</head> | ||
|
||
<body> | ||
<test-fixture id="number-field"> | ||
<template> | ||
<vaadin-number-field></vaadin-number-field> | ||
</template> | ||
</test-fixture> | ||
<script> | ||
describe('events', () => { | ||
let numberField, input; | ||
|
||
describe('has-input-value-changed event', () => { | ||
beforeEach(async() => { | ||
numberField = fixture('number-field'); | ||
input = numberField.inputElement; | ||
}); | ||
|
||
it('should fire the event on input value presence change', async() => { | ||
const hasInputValueChangedSpy = sinon.spy(); | ||
numberField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = '5'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
expect(hasInputValueChangedSpy.calledOnce).to.be.true; | ||
|
||
hasInputValueChangedSpy.reset(); | ||
input.value = ''; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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(); | ||
numberField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = '5'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
hasInputValueChangedSpy.reset(); | ||
|
||
input.value = '56'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>vaadin-password-field events tests</title> | ||
|
||
<script src="../../web-component-tester/browser.js"></script> | ||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<link rel="import" href="../vaadin-password-field.html"> | ||
<link rel="import" href="helpers.html"> | ||
<link rel="import" href="../../test-fixture/test-fixture.html"> | ||
</head> | ||
|
||
<body> | ||
<test-fixture id="password-field"> | ||
<template> | ||
<vaadin-password-field></vaadin-password-field> | ||
</template> | ||
</test-fixture> | ||
<script> | ||
describe('events', () => { | ||
let passwordField, input; | ||
|
||
describe('has-input-value-changed event', () => { | ||
beforeEach(async() => { | ||
passwordField = fixture('password-field'); | ||
input = passwordField.inputElement; | ||
}); | ||
|
||
it('should fire the event on input value presence change', async() => { | ||
const hasInputValueChangedSpy = sinon.spy(); | ||
passwordField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = 'foo'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
expect(hasInputValueChangedSpy.calledOnce).to.be.true; | ||
|
||
hasInputValueChangedSpy.reset(); | ||
input.value = ''; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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(); | ||
passwordField.addEventListener('has-input-value-changed', hasInputValueChangedSpy); | ||
input.value = 'foo'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
hasInputValueChangedSpy.reset(); | ||
|
||
input.value = 'foobar'; | ||
input.dispatchEvent(new CustomEvent('input')); | ||
await nextFrame(); | ||
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
Oops, something went wrong.