3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
12 <meta charset=
"UTF-8">
13 <title>core-selector-content
</title>
14 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0">
16 <script src=
"../../webcomponentsjs/webcomponents.js"></script>
17 <script src=
"../../web-component-tester/browser.js"></script>
19 <link rel=
"import" href=
"../core-selector.html">
30 <polymer-element name=
"test-core-selector" noscript
attributes=
"selected">
32 <core-selector id=
"selector" selected=
"{{selected}}" valueattr=
"id">
38 <test-core-selector selected=
"item0">
39 <div id=
"item0">item0
</div>
40 <div id=
"item1">item1
</div>
41 <div id=
"item2">item2
</div>
42 <div id=
"item3">item3
</div>
47 var s
= document
.querySelector('test-core-selector');
49 suite('content', function() {
51 test('get selected', function(done
) {
52 asyncPlatformFlush(function() {
53 // check selected class
54 assert
.isTrue(s
.children
[0].classList
.contains('core-selected'));
59 test('set selected', function(done
) {
62 asyncPlatformFlush(function() {
63 // check selected class
64 assert
.isTrue(s
.children
[1].classList
.contains('core-selected'));
69 test('get items', function() {
70 assert
.equal(s
.$.selector
.items
.length
, s
.children
.length
);
73 test('activate event', function(done
) {
74 s
.children
[2].dispatchEvent(new CustomEvent('tap', {bubbles
: true}));
75 asyncPlatformFlush(function() {
76 // check selected class
77 assert
.isTrue(s
.children
[2].classList
.contains('core-selected'));
82 test('add item dynamically', function(done
) {
83 var item
= document
.createElement('div');
85 item
.textContent
= 'item4';
89 asyncPlatformFlush(function() {
90 // check selected class
91 assert
.isTrue(s
.children
[4].classList
.contains('core-selected'));