update components

This commit is contained in:
Luke Pulverenti 2016-02-02 15:36:33 -05:00
parent 2371272bd2
commit 5e3ab690af
9 changed files with 92 additions and 27 deletions

View file

@ -19,6 +19,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="test-menubar.html">
</head>
@ -44,6 +45,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
</test-fixture>
<test-fixture id="rtl">
<template>
<div dir="rtl">
<test-menubar>
<div>item 1</div>
<div>item 2</div>
<div>item 3</div>
</test-menubar>
</div>
</template>
</test-fixture>
<script>
suite('menubar a11y tests', function() {
@ -55,9 +68,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('first item gets focus when menubar is focused', function(done) {
var menubar = fixture('basic');
menubar.focus();
MockInteractions.focus(menubar);
setTimeout(function() {
assert.equal(document.activeElement, menubar.firstElementChild, 'document.activeElement is first item')
assert.equal(Polymer.dom(document).activeElement, menubar.firstElementChild, 'document.activeElement is first item')
done();
// wait for async in _onFocus
}, 200);
@ -66,9 +79,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
test('selected item gets focus when menubar is focused', function(done) {
var menubar = fixture('basic');
menubar.selected = 1;
menubar.focus();
MockInteractions.focus(menubar);
setTimeout(function() {
assert.equal(document.activeElement, menubar.selectedItem, 'document.activeElement is selected item');
assert.equal(Polymer.dom(document).activeElement, menubar.selectedItem, 'document.activeElement is selected item');
done();
// wait for async in _onFocus
}, 200);
@ -79,7 +92,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
menubar.selected = 0;
menubar.items[1].click();
setTimeout(function() {
assert.equal(document.activeElement, menubar.items[1], 'document.activeElement is last activated item');
assert.equal(Polymer.dom(document).activeElement, menubar.items[1], 'document.activeElement is last activated item');
done();
// wait for async in _onFocus
}, 200);
@ -90,12 +103,49 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
menubar.selected = 0;
menubar.items[0].click();
setTimeout(function() {
assert.equal(document.activeElement, menubar.items[0], 'document.activeElement is last activated item');
assert.equal(Polymer.dom(document).activeElement, menubar.items[0], 'document.activeElement is last activated item');
done();
// wait for async in _onFocus
}, 200);
});
suite('left / right keys are reversed when the menubar has RTL directionality', function() {
var LEFT = 37;
var RIGHT = 39;
test('left key moves to the next item', function() {
var rtlContainer = fixture('rtl');
var menubar = rtlContainer.querySelector('test-menubar');
menubar.selected = 0;
menubar.items[1].click();
assert.equal(Polymer.dom(document).activeElement, menubar.items[1]);
MockInteractions.pressAndReleaseKeyOn(menubar, LEFT);
assert.equal(Polymer.dom(document).activeElement, menubar.items[2],
'`document.activeElement` should be the next item.');
assert.equal(menubar.selected, 1,
'`menubar.selected` should not change.');
});
test('right key moves to the previous item', function() {
var rtlContainer = fixture('rtl');
var menubar = rtlContainer.querySelector('test-menubar');
menubar.selected = 0;
menubar.items[1].click();
assert.equal(Polymer.dom(document).activeElement, menubar.items[1]);
MockInteractions.pressAndReleaseKeyOn(menubar, RIGHT);
assert.equal(Polymer.dom(document).activeElement, menubar.items[0],
'`document.activeElement` should be the previous item');
assert.equal(menubar.selected, 1,
'`menubar.selected` should not change.');
});
});
});
</script>