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

Side by Side Diff: test/iron_selector_multi_test.dart

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: update pubspec/changelog Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 @TestOn('browser') 4 @TestOn('browser')
5 library polymer_elements.test.iron_selector_multi_test; 5 library polymer_elements.test.iron_selector_multi_test;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'package:polymer_interop/polymer_interop.dart';
8 import 'package:polymer_elements/iron_selector.dart'; 9 import 'package:polymer_elements/iron_selector.dart';
9 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
10 import 'package:web_components/web_components.dart'; 11 import 'package:web_components/web_components.dart';
11 import 'common.dart'; 12 import 'common.dart';
12 13
13 main() async { 14 main() async {
14 await initWebComponents(); 15 await initWebComponents();
15 16
16 group('multi', () { 17 group('multi', () {
17 IronSelector s; 18 IronSelector s;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // tap on already selected item should deselect it 75 // tap on already selected item should deselect it
75 s.children[0].dispatchEvent(new CustomEvent('tap', canBubble: true)); 76 s.children[0].dispatchEvent(new CustomEvent('tap', canBubble: true));
76 // check selectedValues 77 // check selectedValues
77 expect(s.selectedValues.length, 0); 78 expect(s.selectedValues.length, 0);
78 // check class 79 // check class
79 expect(s.children[0].classes.contains('iron-selected'), isFalse); 80 expect(s.children[0].classes.contains('iron-selected'), isFalse);
80 // check events 81 // check events
81 expect(selectEventCounter, 1); 82 expect(selectEventCounter, 1);
82 expect(deselectEventCounter, 1); 83 expect(deselectEventCounter, 1);
83 }); 84 });
85
86 test('fires selected-values-changed when selection changes', () {
87 var selectedValuesChangedEventCounter = 0;
88
89 s.on['selected-values-changed'].listen((e) {
90 selectedValuesChangedEventCounter++;
91 });
92
93 tap(Polymer.dom(s).children[0]);
94 tap(Polymer.dom(s).children[0]);
95 tap(Polymer.dom(s).children[0]);
96
97 expect(selectedValuesChangedEventCounter, isNot(0));
98 });
99
100 test('selects from items created by dom-repeat', () async {
101 var selectEventCounter = 0;
102 var firstChild;
103
104 s = document.querySelector('#repeatedItems');
105 s.on['iron-select'].first.then((e) {
106 selectEventCounter++;
107 });
108
109 // NOTE(cdata): I guess `dom-repeat` doesn't stamp synchronously..
110 await wait(1);
111 firstChild = Polymer.dom(s).querySelector('div');
112 tap(firstChild);
113
114 expect(s.selectedItems[0].text, 'foo');
115 });
84 116
85 /* test('toggle multi from true to false', () { 117 /* test('toggle multi from true to false', () {
86 // set selected 118 // set selected
87 s.selected = [0, 2]; 119 s.selected = [0, 2];
88 var first = s.selected[0]; 120 var first = s.selected[0];
89 // set mutli to false, so to make it single-selection 121 // set mutli to false, so to make it single-selection
90 s.multi = false; 122 s.multi = false;
91 // selected should not be an array 123 // selected should not be an array
92 assert.isNotArray(s.selected); 124 assert.isNotArray(s.selected);
93 // selected should be the first value from the old array 125 // selected should be the first value from the old array
94 expect(s.selected, first); 126 expect(s.selected, first);
95 }); */ 127 }); */
96 128
97 }); 129 });
98 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698