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-next-previous-wrap
</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 <core-selector id=
"selector" selected=
"0">
38 var s
= document
.querySelector('#selector');
40 function assertAndSelect(method
, expectedIndex
, wrap
) {
41 return function(done
) {
42 assert
.equal(s
.selected
, expectedIndex
);
48 suite('next/previous', function() {
50 test('selectNext(true) wraps', function(done
) {
51 assert
.equal(s
.selected
, 0);
54 assertAndSelect('selectNext', 0, true),
55 assertAndSelect('selectNext', 1, true),
56 assertAndSelect('selectNext', 2, true),
58 assert
.equal(s
.selected
, 0);
64 test('selectPrevious(true) wraps', function(done
) {
65 assert
.equal(s
.selected
, 0);
68 assertAndSelect('selectPrevious', 0, true),
69 assertAndSelect('selectPrevious', 2, true),
70 assertAndSelect('selectPrevious', 1, true),
72 assert
.equal(s
.selected
, 0);
78 test('selectNext() does not wrap', function(done
) {
79 assert
.equal(s
.selected
, 0);
82 assertAndSelect('selectNext', 0),
83 assertAndSelect('selectNext', 1),
84 assertAndSelect('selectNext', 2),
85 assertAndSelect('selectNext', 2),
86 assertAndSelect('selectNext', 2),
89 asyncPlatformFlush(done
);
94 test('selectPrevious() does not wrap', function(done
) {
95 assert
.equal(s
.selected
, 0);
100 assertAndSelect('selectPrevious', 2),
101 assertAndSelect('selectPrevious', 1),
102 assertAndSelect('selectPrevious', 0),
103 assertAndSelect('selectPrevious', 0),
104 assertAndSelect('selectPrevious', 0),