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

Side by Side Diff: test/paper_dropdown_menu_test.dart

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates 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
« no previous file with comments | « test/paper_checked_element_behavior_test.html ('k') | test/paper_inky_focus_behavior_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.paper_dropdown_menu_test; 5 library polymer_elements.test.paper_dropdown_menu_test;
6 6
7 import 'package:polymer_elements/paper_dropdown_menu.dart'; 7 import 'package:polymer_elements/paper_dropdown_menu.dart';
8 import 'package:polymer_elements/paper_menu.dart'; 8 import 'package:polymer_elements/paper_menu.dart';
9 import 'package:polymer_interop/polymer_interop.dart'; 9 import 'package:polymer_interop/polymer_interop.dart';
10 import 'package:web_components/web_components.dart'; 10 import 'package:web_components/web_components.dart';
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 group('when a value is preselected', () { 68 group('when a value is preselected', () {
69 setUp(() { 69 setUp(() {
70 dropdownMenu = fixture('PreselectedDropdownMenu'); 70 dropdownMenu = fixture('PreselectedDropdownMenu');
71 }); 71 });
72 72
73 test('the input area shows the correct selection', () { 73 test('the input area shows the correct selection', () {
74 var secondItem = Polymer.dom(dropdownMenu).querySelectorAll('paper-item' )[1]; 74 var secondItem = Polymer.dom(dropdownMenu).querySelectorAll('paper-item' )[1];
75 expect(dropdownMenu.selectedItem, secondItem); 75 expect(dropdownMenu.selectedItem, secondItem);
76 }); 76 });
77 }); 77 });
78
79 group('deselecting', () {
80 var menu;
81
82 setUp(() {
83 dropdownMenu = fixture('PreselectedDropdownMenu');
84 menu = Polymer.dom(dropdownMenu).querySelector('.dropdown-content');
85 });
86
87 test('an `iron-deselect` event clears the current selection', () {
88 menu.selected = null;
89 expect(dropdownMenu.selectedItem, null);
90 });
91 });
92
93 group('validation', () {
94 var menu;
95
96 test('a non required dropdown is valid regardless of its selection', () {
97 PaperDropdownMenu dropdownMenu = fixture('TrivialDropdownMenu');
98 menu = Polymer.dom(dropdownMenu).querySelector('.dropdown-content');
99
100 // no selection.
101 expect(dropdownMenu.validate(null), isTrue);
102 expect(dropdownMenu.invalid, isFalse);
103 expect(dropdownMenu.value, isNull);
104
105 // some selection.
106 menu.selected = 1;
107 expect(dropdownMenu.validate(null), isTrue);
108 expect(dropdownMenu.invalid, isFalse);
109 expect(dropdownMenu.value, 'Bar');
110 });
111
112 test('a required dropdown is invalid without a selection', () {
113 PaperDropdownMenu dropdownMenu = fixture('TrivialDropdownMenu');
114 dropdownMenu.required = true;
115
116 // no selection.
117 expect(dropdownMenu.validate(null), isFalse);
118 expect(dropdownMenu.invalid, isTrue);
119 expect(dropdownMenu.value, isNull);
120 });
121
122 test('a required dropdown is valid with a selection', () {
123 PaperDropdownMenu dropdownMenu = fixture('PreselectedDropdownMenu');
124 dropdownMenu.required = true;
125
126 expect(dropdownMenu.validate(null), isTrue);
127 expect(dropdownMenu.invalid, isFalse);
128 expect(dropdownMenu.value, 'Bar');
129 });
130 });
78 }); 131 });
79 } 132 }
OLDNEW
« no previous file with comments | « test/paper_checked_element_behavior_test.html ('k') | test/paper_inky_focus_behavior_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698