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

Unified Diff: pkg/polymer/test/attr_deserialize_test.dart

Issue 24149003: Port of github.com/polymer/polymer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 3 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
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/polymer/test/attr_deserialize_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/attr_deserialize_test.dart
diff --git a/pkg/polymer/test/attr_deserialize_test.dart b/pkg/polymer/test/attr_deserialize_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8497752194c59eab80f7ecd26f83720c3e4e7c8a
--- /dev/null
+++ b/pkg/polymer/test/attr_deserialize_test.dart
@@ -0,0 +1,45 @@
+// 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:html';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'package:polymer/polymer.dart';
+
+@CustomTag('my-element')
+class MyElement extends PolymerElement {
+ @published double volume;
+ @published int factor;
+ @published bool crankIt;
+ @published String msg;
+ @published DateTime time;
+ @published Object json;
+}
+
+main() {
+ useHtmlConfiguration();
+
+ test('attributes were deserialized', () {
+ MyElement elem = query('my-element').xtag;
+ final msg = 'property should match attribute.';
+ expect(elem.volume, 11.0, reason: '"volume" should match attribute');
+ expect(elem.factor, 3, reason: '"factor" should match attribute');
+ expect(elem.crankIt, true, reason: '"crankIt" should match attribute');
+ expect(elem.msg, "Yo!", reason: '"msg" should match attribute');
+ expect(elem.time, DateTime.parse('2013-08-08T18:34Z'),
+ reason: '"time" should match attribute');
+ expect(elem.json, {'here': 'is', 'some': 'json', 'x': 123},
+ reason: '"json" should match attribute');
+
+ var text = elem.shadowRoot.text;
+ // Collapse adjacent whitespace like a browser would:
+ text = text.replaceAll('\n', ' ').replaceAll(new RegExp(r'\s+'), ' ');
+
+ // Note: using "${33.0}" because the toString differs in JS vs Dart VM.
+ expect(text, " Yo! The volume is ${33.0} !! The time is "
+ "2013-08-08 18:34:00.000Z and here's some JSON: "
+ "{here: is, some: json, x: 123} ",
+ reason: 'text should match expected HTML template');
+ });
+}
« no previous file with comments | « pkg/polymer/pubspec.yaml ('k') | pkg/polymer/test/attr_deserialize_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698