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

Unified Diff: packages/polymer_expressions/test/globals_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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: packages/polymer_expressions/test/globals_test.dart
diff --git a/packages/polymer_expressions/test/globals_test.dart b/packages/polymer_expressions/test/globals_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5b147992ec95329c2d0732f6620b4bdf27c27edf
--- /dev/null
+++ b/packages/polymer_expressions/test/globals_test.dart
@@ -0,0 +1,94 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:html';
+
+import 'package:observe/observe.dart';
+import 'package:observe/mirrors_used.dart'; // make test smaller.
+import 'package:smoke/mirrors.dart' as smoke;
+import 'package:polymer_expressions/polymer_expressions.dart';
+import 'package:template_binding/template_binding.dart';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+
+main() {
+ useHtmlConfiguration();
+ smoke.useMirrors();
+
+ var testDiv;
+ group('enumerate', () {
+ setUp(() {
+ testDiv = new Element.html('''
+ <div id="test">
+ <template bind>
+ <template repeat="{{entry in this | enumerate}}">
+ <div>Item {{ entry.index }} is {{ entry.value }}</div>
+ </template>
+ </template>
+ </div>''');
+ TemplateBindExtension.bootstrap(testDiv);
+ document.body.nodes.add(testDiv);
+ });
+
+ tearDown(() {
+ testDiv.remove();
+ testDiv = null;
+ });
+
+ test('should enumerate item and index', () {
+ templateBind(testDiv.query('template'))
+ ..bindingDelegate = new PolymerExpressions()
+ ..model = toObservable(
+ ['hello', 'from', 'polymer', 'expressions']);
+
+ return new Future(() {
+ expect(testDiv.queryAll('div').map((n) => n.text), [
+ 'Item 0 is hello',
+ 'Item 1 is from',
+ 'Item 2 is polymer',
+ 'Item 3 is expressions',
+ ]);
+ });
+ });
+
+ test('should update after changes', () {
+ var model = toObservable(
+ ['hello', 'from', 'polymer', 'expressions', 'a', 'b', 'c']);
+
+ templateBind(testDiv.query('template'))
+ ..bindingDelegate = new PolymerExpressions()
+ ..model = model;
+
+ return new Future(() {
+ expect(testDiv.queryAll('div').map((n) => n.text), [
+ 'Item 0 is hello',
+ 'Item 1 is from',
+ 'Item 2 is polymer',
+ 'Item 3 is expressions',
+ 'Item 4 is a',
+ 'Item 5 is b',
+ 'Item 6 is c',
+ ]);
+
+ model.removeAt(1);
+ model[1] = 'world';
+ model[2] = '!';
+ model.insert(5, 'e');
+
+ return new Future(() {
+ expect(testDiv.queryAll('div').map((n) => n.text), [
+ 'Item 0 is hello',
+ 'Item 1 is world',
+ 'Item 2 is !',
+ 'Item 3 is a',
+ 'Item 4 is b',
+ 'Item 5 is e',
+ 'Item 6 is c',
+ ]);
+ });
+ });
+ });
+ });
+}
« no previous file with comments | « packages/polymer_expressions/test/eval_test.dart ('k') | packages/polymer_expressions/test/globals_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698