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

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: 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
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..0f77251b57e7c4aff2e165e44f6d65a0de12e33f
--- /dev/null
+++ b/pkg/polymer/test/attr_deserialize_test.dart
@@ -0,0 +1,44 @@
+// 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+'), ' ');
+
+ 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');
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698