Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: polymer_1.0.4/bower_components/iron-selector/test/basic.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: polymer_1.0.4/bower_components/iron-selector/test/basic.html
diff --git a/polymer_1.0.4/bower_components/iron-selector/test/basic.html b/polymer_1.0.4/bower_components/iron-selector/test/basic.html
new file mode 100644
index 0000000000000000000000000000000000000000..602de183f85ddb32f9f01025350fcb9c3465119d
--- /dev/null
+++ b/polymer_1.0.4/bower_components/iron-selector/test/basic.html
@@ -0,0 +1,150 @@
+<!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>
+
+ <title>iron-selector-basic</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
+
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
+ <script src="../../web-component-tester/browser.js"></script>
+ <script src="../../test-fixture/test-fixture-mocha.js"></script>
+
+ <link rel="import" href="../../test-fixture/test-fixture.html">
+ <link rel="import" href="../iron-selector.html">
+
+ <style>
+ .iron-selected {
+ background: #ccc;
+ }
+
+ .my-selected {
+ background: red;
+ }
+ </style>
+
+</head>
+<body>
+
+ <test-fixture id="defaults">
+ <template>
+ <iron-selector>
+ <div>Item 0</div>
+ <div>Item 1</div>
+ <div>Item 2</div>
+ <div>Item 3</div>
+ <div>Item 4</div>
+ </iron-selector>
+ </template>
+ </test-fixture>
+
+ <br><br>
+
+ <test-fixture id="basic">
+ <template>
+ <iron-selector selected="item2" attr-for-selected="id">
+ <div id="item0">Item 0</div>
+ <div id="item1">Item 1</div>
+ <div id="item2">Item 2</div>
+ <div id="item3">Item 3</div>
+ <div id="item4">Item 4</div>
+ </iron-selector>
+ </template>
+ </test-fixture>
+
+ <script>
+
+ suite('defaults', function() {
+
+ var s1;
+
+ setup(function () {
+ s1 = fixture('defaults');
+ });
+
+ test('to nothing selected', function() {
+ assert.equal(s1.selected, null);
+ });
+
+ test('to iron-selected as selectedClass', function() {
+ assert.equal(s1.selectedClass, 'iron-selected');
+ });
+
+ test('to false as multi', function() {
+ assert.isFalse(s1.multi);
+ });
+
+ test('to tap as activateEvent', function() {
+ assert.equal(s1.activateEvent, 'tap');
+ });
+
+ test('to nothing as attrForSelected', function() {
+ assert.equal(s1.attrForSelected, null);
+ });
+
+ test('as many items as children', function() {
+ assert.equal(s1.items.length, s1.querySelectorAll('div').length);
+ });
+ });
+
+ suite('basic', function() {
+
+ var s2;
+
+ setup(function () {
+ s2 = fixture('basic');
+ });
+
+ test('honors the attrForSelected attribute', function() {
+ assert.equal(s2.attrForSelected, 'id');
+ assert.equal(s2.selected, 'item2');
+ assert.equal(s2.selectedItem, document.querySelector('#item2'));
+ });
+
+ test('allows assignment to selected', function() {
+ // set selected
+ s2.selected = 'item4';
+ // check selected class
+ assert.isTrue(s2.children[4].classList.contains('iron-selected'));
+ // check item
+ assert.equal(s2.selectedItem, s2.children[4]);
+ });
+
+ test('fire iron-select when selected is set', function() {
+ // setup listener for iron-select event
+ var selectedEventCounter = 0;
+ s2.addEventListener('iron-select', function(e) {
+ selectedEventCounter++;
+ });
+ // set selected
+ s2.selected = 'item4';
+ // check iron-select event
+ assert.equal(selectedEventCounter, 1);
+ });
+
+ test('set selected to old value', function() {
+ // setup listener for iron-select event
+ var selectedEventCounter = 0;
+ s2.addEventListener('iron-select', function(e) {
+ selectedEventCounter++;
+ });
+ // selecting the same value shouldn't fire iron-select
+ s2.selected = 'item2';
+ assert.equal(selectedEventCounter, 0);
+ });
+
+ });
+
+ </script>
+
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698