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

Unified Diff: pkg/polymer/test/take_attributes_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/test/publish_attributes_test.html ('k') | pkg/polymer/test/take_attributes_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/take_attributes_test.dart
diff --git a/pkg/polymer/test/take_attributes_test.dart b/pkg/polymer/test/take_attributes_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a9e409f35a152b7e1479092cb0e3de6ee232c0a8
--- /dev/null
+++ b/pkg/polymer/test/take_attributes_test.dart
@@ -0,0 +1,109 @@
+// 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('x-foo')
+class XFoo extends PolymerElement {
+ @published bool boolean = false;
+ @published num number = 42;
+ @published String str = "don't panic";
+}
+
+@CustomTag('x-bar')
+class XBar extends PolymerElement {
+ @observable bool boolean = false;
+ @observable num number = 42;
+ @observable String str = "don't panic";
+}
+
+@CustomTag('x-zot')
+class XZot extends XBar {
+ @observable num number = 84;
+}
+
+@CustomTag('x-date')
+class XDate extends PolymerElement {
+ @observable var value = new DateTime(2013, 9, 25);
+}
+
+@CustomTag('x-array')
+class XArray extends PolymerElement {
+ @observable List values;
+}
+
+@CustomTag('x-obj')
+class XObj extends PolymerElement {
+ @observable var values = {};
+}
+
+main() {
+ useHtmlConfiguration();
+
+ test('take attributes', () {
+ queryXTag(x) => document.query(x).xtag;
+
+ expect(queryXTag("#foo0").boolean, true);
+ expect(queryXTag("#foo1").boolean, false);
+ expect(queryXTag("#foo2").boolean, true);
+ expect(queryXTag("#foo3").boolean, false);
+ // this one is only 'truthy'
+ expect(queryXTag("#foo4").boolean, true);
+ // this one is also 'truthy', but should it be?
+ expect(queryXTag("#foo5").boolean, true);
+ //
+ expect(queryXTag("#foo0").number, 42);
+ expect(queryXTag("#foo0").str, "don't panic");
+ //
+ expect(queryXTag("#bar0").boolean, true);
+ expect(queryXTag("#bar1").boolean, false);
+ expect(queryXTag("#bar2").boolean, true);
+ expect(queryXTag("#bar3").boolean, false);
+ // this one is only 'truthy'
+ expect(queryXTag("#bar4").boolean, true);
+ // this one is also 'truthy', but should it be?
+ expect(queryXTag("#bar5").boolean, true);
+ //
+ expect(queryXTag("#bar0").number, 42);
+ expect(queryXTag("#bar0").str, "don't panic");
+ //
+ expect(queryXTag("#zot0").boolean, true);
+ expect(queryXTag("#zot1").boolean, false);
+ expect(queryXTag("#zot2").boolean, true);
+ expect(queryXTag("#zot3").boolean, false);
+ // this one is only 'truthy'
+ expect(queryXTag("#zot4").boolean, true);
+ // this one is also 'truthy', but should it be?
+ expect(queryXTag("#zot5").boolean, true);
+ //
+ expect(queryXTag("#zot0").number, 84);
+ expect(queryXTag("#zot6").number, 185);
+ expect(queryXTag("#zot0").str, "don't panic");
+ //
+ // Date deserialization tests
+ expect(queryXTag("#date1").value, new DateTime(2014, 12, 25));
+ expect(queryXTag("#date2").value, isNot(equals(new DateTime(2014, 12, 25))),
+ reason: 'Dart does not support this format');
+ expect(queryXTag("#date3").value, new DateTime(2014, 12, 25, 11, 45));
+ expect(queryXTag("#date4").value, new DateTime(2014, 12, 25, 11, 45, 30));
+ // Failures on Firefox. Need to fix this with custom parsing
+ //expect(String(queryXTag("#date5").value), String(new Date(2014, 11, 25, 11, 45, 30)));
+ //
+ // milliseconds in the Date string not supported on Firefox
+ //expect(queryXTag("#date5").value.getMilliseconds(), new Date(2014, 11, 25, 11, 45, 30, 33).getMilliseconds());
+ //
+ // Array deserialization tests
+ expect(queryXTag("#arr1").values, [0, 1, 2]);
+ expect(queryXTag("#arr2").values, [33]);
+ // Object deserialization tests
+ expect(queryXTag("#obj1").values, { 'name': 'Brandon',
+ 'nums': [1, 22, 33] });
+ expect(queryXTag("#obj2").values, { "color": "Red" });
+ expect(queryXTag("#obj3").values, { 'movie': 'Buckaroo Banzai',
+ 'DOB': '07/31/1978' });
+ });
+}
« no previous file with comments | « pkg/polymer/test/publish_attributes_test.html ('k') | pkg/polymer/test/take_attributes_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698