mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
02e924e3c5
commit
05b25af69f
55 changed files with 1554 additions and 907 deletions
|
@ -1,15 +1,11 @@
|
|||
<!doctype html>
|
||||
<!--
|
||||
<!DOCTYPE html><!--
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
--><html><head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<title>Tests</title>
|
||||
|
@ -19,7 +15,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
<body>
|
||||
|
||||
<script>
|
||||
|
||||
WCT.loadSuites([
|
||||
'activate-event.html',
|
||||
'basic.html',
|
||||
|
@ -29,10 +24,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
'selected-attribute.html',
|
||||
'template-repeat.html',
|
||||
'content.html',
|
||||
'excluded-local-names.html'
|
||||
'excluded-local-names.html',
|
||||
'activate-event.html?dom=shadow',
|
||||
'basic.html?dom=shadow',
|
||||
'multi.html?dom=shadow',
|
||||
'next-previous.html?dom=shadow',
|
||||
'selected-attribute.html?dom=shadow',
|
||||
'template-repeat.html?dom=shadow',
|
||||
'content.html?dom=shadow',
|
||||
'excluded-local-names.html?dom=shadow'
|
||||
]);
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
</body></html>
|
||||
|
|
|
@ -93,8 +93,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
test('set multi-selection via tap', function() {
|
||||
// set selectedValues
|
||||
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
s.children[2].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
MockInteractions.tap(s.children[0]);
|
||||
MockInteractions.tap(s.children[2]);
|
||||
// check selected class
|
||||
assert.isTrue(s.children[0].classList.contains('iron-selected'));
|
||||
assert.isTrue(s.children[2].classList.contains('iron-selected'));
|
||||
|
@ -104,31 +104,106 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
assert.equal(s.selectedItems[1], s.children[2]);
|
||||
});
|
||||
|
||||
test('fire iron-select/deselect events', function() {
|
||||
// setup listener for iron-select event
|
||||
var selectEventCounter = 0;
|
||||
test('fire iron-select/deselect events when selectedValues changes', function() {
|
||||
// setup listener for iron-select/deselect events
|
||||
var items = [s.children[0], s.children[1], s.children[2]],
|
||||
selectEventCounters = [0, 0, 0],
|
||||
deselectEventCounters = [0, 0, 0];
|
||||
|
||||
s.addEventListener('iron-select', function(e) {
|
||||
selectEventCounter++;
|
||||
selectEventCounters[items.indexOf(e.detail.item)]++;
|
||||
});
|
||||
// setup listener for core-deselect event
|
||||
var deselectEventCounter = 0;
|
||||
s.addEventListener('iron-deselect', function(e) {
|
||||
deselectEventCounter++;
|
||||
deselectEventCounters[items.indexOf(e.detail.item)]++;
|
||||
});
|
||||
// tap to select an item
|
||||
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
|
||||
// programatically select values 0 and 1 (both fire select)
|
||||
s.selectedValues = [0, 1];
|
||||
|
||||
// programatically select values 1 and 2 (2 fires select, 0 fires deselect)
|
||||
s.selectedValues = [1, 2];
|
||||
|
||||
// programatically deselect all values (1 and 2 fire deselect)
|
||||
s.selectedValues = [];
|
||||
|
||||
// check events
|
||||
assert.equal(selectEventCounter, 1);
|
||||
assert.equal(deselectEventCounter, 0);
|
||||
// tap on already selected item should deselect it
|
||||
s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true}));
|
||||
// check selectedValues
|
||||
assert.equal(s.selectedValues.length, 0);
|
||||
// check class
|
||||
assert.isFalse(s.children[0].classList.contains('iron-selected'));
|
||||
assert.equal(selectEventCounters[0], 1);
|
||||
assert.equal(deselectEventCounters[0], 1);
|
||||
assert.equal(selectEventCounters[1], 1);
|
||||
assert.equal(deselectEventCounters[1], 1);
|
||||
assert.equal(selectEventCounters[2], 1);
|
||||
assert.equal(deselectEventCounters[2], 1);
|
||||
});
|
||||
|
||||
test('fire iron-select/deselect events when toggling items', function() {
|
||||
// setup listener for iron-select/deselect events
|
||||
var items = [s.children[0], s.children[1], s.children[2]],
|
||||
selectEventCounters = [0, 0, 0],
|
||||
deselectEventCounters = [0, 0, 0];
|
||||
|
||||
s.addEventListener('iron-select', function(e) {
|
||||
selectEventCounters[items.indexOf(e.detail.item)]++;
|
||||
});
|
||||
s.addEventListener('iron-deselect', function(e) {
|
||||
deselectEventCounters[items.indexOf(e.detail.item)]++;
|
||||
});
|
||||
|
||||
// tap to select items 0 and 1 (both fire select)
|
||||
MockInteractions.tap(items[0]);
|
||||
MockInteractions.tap(items[1]);
|
||||
|
||||
// programatically select values 1 and 2 (2 fires select, 0 fires deselect)
|
||||
s.selectedValues = [1, 2];
|
||||
|
||||
// tap to deselect items 1 and 2 (both fire deselect)
|
||||
MockInteractions.tap(items[1]);
|
||||
MockInteractions.tap(items[2]);
|
||||
|
||||
// check events
|
||||
assert.equal(selectEventCounter, 1);
|
||||
assert.equal(deselectEventCounter, 1);
|
||||
assert.equal(selectEventCounters[0], 1);
|
||||
assert.equal(deselectEventCounters[0], 1);
|
||||
assert.equal(selectEventCounters[1], 1);
|
||||
assert.equal(deselectEventCounters[1], 1);
|
||||
assert.equal(selectEventCounters[2], 1);
|
||||
assert.equal(deselectEventCounters[2], 1);
|
||||
});
|
||||
|
||||
test('toggle iron-selected class when toggling items selection', function() {
|
||||
// setup listener for iron-item-select/deselect events
|
||||
var item0 = s.children[0], item1 = s.children[1];
|
||||
|
||||
assert.isFalse(item0.classList.contains('iron-selected'));
|
||||
assert.isFalse(item1.classList.contains('iron-selected'));
|
||||
|
||||
// tap to select item 0 (add iron-selected class)
|
||||
MockInteractions.tap(item0);
|
||||
|
||||
assert.isTrue(item0.classList.contains('iron-selected'));
|
||||
assert.isFalse(item1.classList.contains('iron-selected'));
|
||||
|
||||
// tap to select item 1 (add iron-selected class)
|
||||
MockInteractions.tap(item1);
|
||||
|
||||
assert.isTrue(item0.classList.contains('iron-selected'));
|
||||
assert.isTrue(item1.classList.contains('iron-selected'));
|
||||
|
||||
// tap to deselect item 1 (remove iron-selected class)
|
||||
MockInteractions.tap(item1);
|
||||
|
||||
assert.isTrue(item0.classList.contains('iron-selected'));
|
||||
assert.isFalse(item1.classList.contains('iron-selected'));
|
||||
|
||||
// programatically select both values (1 add iron-selected class)
|
||||
s.selectedValues = [0, 1];
|
||||
|
||||
assert.isTrue(item0.classList.contains('iron-selected'));
|
||||
assert.isTrue(item1.classList.contains('iron-selected'));
|
||||
|
||||
// programatically deselect all values (both removes iron-selected class)
|
||||
s.selectedValues = [];
|
||||
|
||||
assert.isFalse(item0.classList.contains('iron-selected'));
|
||||
assert.isFalse(item1.classList.contains('iron-selected'));
|
||||
});
|
||||
|
||||
test('fires selected-values-changed when selection changes', function() {
|
||||
|
@ -180,10 +255,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
Polymer.dom(s).removeChild(lastChild);
|
||||
|
||||
Polymer.Base.async(function() {
|
||||
expect(s.selectedItems.length).to.be.equal(1);
|
||||
done();
|
||||
});
|
||||
Polymer.dom.flush();
|
||||
|
||||
expect(s.selectedItems.length).to.be.equal(1);
|
||||
expect(s.selectedItems[0]).to.be.equal(firstChild);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -43,6 +43,28 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="test-attr-change">
|
||||
<template>
|
||||
<iron-selector id="selector" attr-for-selected="data-x" selected="x-1">
|
||||
<div data-x="x-1" data-y="y-1">1</div>
|
||||
<div data-x="x-2" data-y="y-2">2</div>
|
||||
<div data-x="x-3" data-y="y-3">3</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="test-attr-change-multi">
|
||||
<template>
|
||||
<iron-selector multi id="selector"
|
||||
attr-for-selected="data-x"
|
||||
selected-values='["x-1","x-2"]'>
|
||||
<div data-x="x-1" data-y="y-1">1</div>
|
||||
<div data-x="x-2" data-y="y-2">2</div>
|
||||
<div data-x="x-3" data-y="y-3">3</div>
|
||||
</iron-selector>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('selected attributes', function() {
|
||||
|
@ -66,6 +88,40 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
});
|
||||
|
||||
suite('changing attrForSelected', function() {
|
||||
|
||||
var s;
|
||||
|
||||
setup(function () {
|
||||
s = fixture('test-attr-change');
|
||||
});
|
||||
|
||||
test('changing selectedAttribute', function() {
|
||||
Polymer.dom.flush();
|
||||
s.attrForSelected = 'data-y';
|
||||
assert.equal(s.selected, 'y-1');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('changing attrForSelected in multi', function() {
|
||||
|
||||
var s;
|
||||
|
||||
setup(function () {
|
||||
s = fixture('test-attr-change-multi');
|
||||
});
|
||||
|
||||
test('changing selectedAttribute', function() {
|
||||
Polymer.dom.flush();
|
||||
s.attrForSelected = 'data-y';
|
||||
assert.equal(s.selectedValues.length, 2);
|
||||
assert.equal(s.selectedValues[0],'y-1');
|
||||
assert.equal(s.selectedValues[1],'y-2');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue