-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fire internal-tabbing on Tab, focus first input, add tests * Add event documentation * Rename to internal-tab * Fire an event in tests
- Loading branch information
Showing
6 changed files
with
114 additions
and
2 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
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,80 @@ | ||
<!doctype html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>vaadin-custom-field tests</title> | ||
<script src="../../web-component-tester/browser.js"></script> | ||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<script src="../../iron-test-helpers/mock-interactions.js"></script> | ||
<link rel="import" href="../../test-fixture/test-fixture.html"> | ||
<link rel="import" href="../vaadin-custom-field.html"> | ||
<link rel="import" href="helpers.html"> | ||
</head> | ||
|
||
<body> | ||
<test-fixture id="default"> | ||
<template> | ||
<vaadin-custom-field> | ||
<input type="text"> | ||
<input type="text"> | ||
<input type="number"> | ||
<input type="number"> | ||
</vaadin-custom-field> | ||
</template> | ||
</test-fixture> | ||
|
||
<script> | ||
describe('keyboard navigation', function() { | ||
var customField; | ||
|
||
function tab(target) { | ||
MockInteractions.keyDownOn(target, 9, [], 'Tab'); | ||
} | ||
|
||
function shiftTab(target) { | ||
MockInteractions.keyDownOn(target, 9, 'shift', 'Tab'); | ||
} | ||
|
||
beforeEach(function() { | ||
customField = fixture('default'); | ||
}); | ||
|
||
it('should fire `internal-tab` event on Tab', () => { | ||
const internalTabSpy = sinon.spy(); | ||
customField.addEventListener('internal-tab', internalTabSpy); | ||
for (let i = 0; i < 3; i ++) { | ||
tab(customField.inputs[i]); | ||
} | ||
|
||
expect(internalTabSpy.callCount).to.equal(3); | ||
}); | ||
|
||
it('should not fire `internal-tab` event on Tab from the last input', () => { | ||
const internalTabSpy = sinon.spy(); | ||
customField.addEventListener('internal-tab', internalTabSpy); | ||
tab(customField.inputs[3]); | ||
|
||
expect(internalTabSpy).not.to.be.called; | ||
}); | ||
|
||
it('should fire `internal-tab` event on Shift Tab', () => { | ||
const internalTabSpy = sinon.spy(); | ||
customField.addEventListener('internal-tab', internalTabSpy); | ||
for (let i = 3; i > 0; i --) { | ||
shiftTab(customField.inputs[i]); | ||
} | ||
|
||
expect(internalTabSpy.callCount).to.equal(3); | ||
}); | ||
|
||
it('should not fire `internal-tab` event on Shift Tab from the first input', () => { | ||
const internalTabSpy = sinon.spy(); | ||
customField.addEventListener('internal-tab', internalTabSpy); | ||
shiftTab(customField.inputs[0]); | ||
|
||
expect(internalTabSpy).not.to.be.called; | ||
}); | ||
|
||
}); | ||
</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