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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:html';
6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart';
8 import 'package:polymer/polymer.dart';
9
10 @CustomTag('x-foo')
11 class XFoo extends PolymerElement {
12 @published bool boolean = false;
13 @published num number = 42;
14 @published String str = "don't panic";
15 }
16
17 @CustomTag('x-bar')
18 class XBar extends PolymerElement {
19 @observable bool boolean = false;
20 @observable num number = 42;
21 @observable String str = "don't panic";
22 }
23
24 @CustomTag('x-zot')
25 class XZot extends XBar {
26 @observable num number = 84;
27 }
28
29 @CustomTag('x-date')
30 class XDate extends PolymerElement {
31 @observable var value = new DateTime(2013, 9, 25);
32 }
33
34 @CustomTag('x-array')
35 class XArray extends PolymerElement {
36 @observable List values;
37 }
38
39 @CustomTag('x-obj')
40 class XObj extends PolymerElement {
41 @observable var values = {};
42 }
43
44 main() {
45 useHtmlConfiguration();
46
47 test('take attributes', () {
48 queryXTag(x) => document.query(x).xtag;
49
50 expect(queryXTag("#foo0").boolean, true);
51 expect(queryXTag("#foo1").boolean, false);
52 expect(queryXTag("#foo2").boolean, true);
53 expect(queryXTag("#foo3").boolean, false);
54 // this one is only 'truthy'
55 expect(queryXTag("#foo4").boolean, true);
56 // this one is also 'truthy', but should it be?
57 expect(queryXTag("#foo5").boolean, true);
58 //
59 expect(queryXTag("#foo0").number, 42);
60 expect(queryXTag("#foo0").str, "don't panic");
61 //
62 expect(queryXTag("#bar0").boolean, true);
63 expect(queryXTag("#bar1").boolean, false);
64 expect(queryXTag("#bar2").boolean, true);
65 expect(queryXTag("#bar3").boolean, false);
66 // this one is only 'truthy'
67 expect(queryXTag("#bar4").boolean, true);
68 // this one is also 'truthy', but should it be?
69 expect(queryXTag("#bar5").boolean, true);
70 //
71 expect(queryXTag("#bar0").number, 42);
72 expect(queryXTag("#bar0").str, "don't panic");
73 //
74 expect(queryXTag("#zot0").boolean, true);
75 expect(queryXTag("#zot1").boolean, false);
76 expect(queryXTag("#zot2").boolean, true);
77 expect(queryXTag("#zot3").boolean, false);
78 // this one is only 'truthy'
79 expect(queryXTag("#zot4").boolean, true);
80 // this one is also 'truthy', but should it be?
81 expect(queryXTag("#zot5").boolean, true);
82 //
83 expect(queryXTag("#zot0").number, 84);
84 expect(queryXTag("#zot6").number, 185);
85 expect(queryXTag("#zot0").str, "don't panic");
86 //
87 // Date deserialization tests
88 expect(queryXTag("#date1").value, new DateTime(2014, 12, 25));
89 expect(queryXTag("#date2").value, isNot(equals(new DateTime(2014, 12, 25))),
90 reason: 'Dart does not support this format');
91 expect(queryXTag("#date3").value, new DateTime(2014, 12, 25, 11, 45));
92 expect(queryXTag("#date4").value, new DateTime(2014, 12, 25, 11, 45, 30));
93 // Failures on Firefox. Need to fix this with custom parsing
94 //expect(String(queryXTag("#date5").value), String(new Date(2014, 11, 25, 11 , 45, 30)));
95 //
96 // milliseconds in the Date string not supported on Firefox
97 //expect(queryXTag("#date5").value.getMilliseconds(), new Date(2014, 11, 25, 11, 45, 30, 33).getMilliseconds());
98 //
99 // Array deserialization tests
100 expect(queryXTag("#arr1").values, [0, 1, 2]);
101 expect(queryXTag("#arr2").values, [33]);
102 // Object deserialization tests
103 expect(queryXTag("#obj1").values, { 'name': 'Brandon',
104 'nums': [1, 22, 33] });
105 expect(queryXTag("#obj2").values, { "color": "Red" });
106 expect(queryXTag("#obj3").values, { 'movie': 'Buckaroo Banzai',
107 'DOB': '07/31/1978' });
108 });
109 }
OLDNEW
« 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