@@ -3,10 +3,9 @@ library test_lib.test_lib;
33import 'package:guinness/guinness.dart' as gns;
44export 'package:guinness/guinness.dart' hide Expect, expect, NotExpect, beforeEach, it, iit, xit;
55import 'package:unittest/unittest.dart' hide expect;
6- import 'dart:mirrors' ;
6+
77import 'dart:async' ;
88
9- import 'package:collection/equality.dart' ;
109import 'package:angular2/src/dom/dom_adapter.dart' show DOM;
1110
1211import 'package:angular2/src/reflection/reflection.dart' ;
@@ -82,10 +81,8 @@ class Expect extends gns.Expect {
8281
8382 NotExpect get not => new NotExpect (actual);
8483
85- // TODO(tbosch) change back when https://github.com/vsavkin/guinness/issues/41 is fixed
86- // void toEqual(expected) => toHaveSameProps(expected);
87- void toEqual (expected) => _expect (actual, new FixedSamePropsMatcher (expected));
88- void toThrowError ([message= "" ]) => this .toThrowWith (message: message);
84+ void toEqual (expected) => toHaveSameProps (expected);
85+ void toThrowError ([message= "" ]) => toThrowWith (message: message);
8986 void toBePromise () => _expect (actual is Future , equals (true ));
9087 void toImplement (expected) => toBeA (expected);
9188 void toBeNaN () => _expect (double .NAN .compareTo (actual) == 0 , equals (true ));
@@ -96,9 +93,7 @@ class Expect extends gns.Expect {
9693class NotExpect extends gns.NotExpect {
9794 NotExpect (actual) : super (actual);
9895
99- // TODO(tbosch) change back when https://github.com/vsavkin/guinness/issues/41 is fixed
100- // void toEqual(expected) => toHaveSameProps(expected);
101- void toEqual (expected) => _expect (actual, isNot (new FixedSamePropsMatcher (expected)));
96+ void toEqual (expected) => toHaveSameProps (expected);
10297 void toBePromise () => _expect (actual is Future , equals (false ));
10398 Function get _expect => gns.guinness.matchers.expect;
10499}
@@ -155,66 +150,6 @@ xit(name, fn) {
155150 _it (gns.xit, name, fn);
156151}
157152
158- // TODO(tbosch): remove when https://github.com/vsavkin/guinness/issues/41
159- // is fixed
160- class FixedSamePropsMatcher extends Matcher {
161- final Object _expected;
162-
163- const FixedSamePropsMatcher (this ._expected);
164-
165- bool matches (actual, Map matchState) {
166- return compare (toData (_expected), toData (actual));
167- }
168-
169- Description describeMismatch (item, Description mismatchDescription,
170- Map matchState, bool verbose) =>
171- mismatchDescription.add ('is equal to ${toData (item )}. Expected: ${toData (_expected )}' );
172-
173- Description describe (Description description) =>
174- description.add ('has different properties' );
175-
176- toData (obj) => new _FixedObjToData ().call (obj);
177- compare (d1, d2) => new DeepCollectionEquality ().equals (d1, d2);
178- }
179-
180- // TODO(tbosch): remove when https://github.com/vsavkin/guinness/issues/41
181- // is fixed
182- class _FixedObjToData {
183- final visitedObjects = new Set ();
184-
185- call (obj) {
186- if (visitedObjects.contains (obj)) return null ;
187- visitedObjects.add (obj);
188-
189- if (obj is num || obj is String || obj is bool ) return obj;
190- if (obj is Iterable ) return obj.map (call).toList ();
191- if (obj is Map ) return mapToData (obj);
192- return toDataUsingReflection (obj);
193- }
194-
195- mapToData (obj) {
196- var res = {};
197- obj.forEach ((k,v) {
198- res[call (k)] = call (v);
199- });
200- return res;
201- }
202-
203- toDataUsingReflection (obj) {
204- final clazz = reflectClass (obj.runtimeType);
205- final instance = reflect (obj);
206-
207- return clazz.declarations.values.fold ({}, (map, decl) {
208- if (decl is VariableMirror && ! decl.isPrivate && ! decl.isStatic) {
209- final field = instance.getField (decl.simpleName);
210- final name = MirrorSystem .getName (decl.simpleName);
211- map[name] = call (field.reflectee);
212- }
213- return map;
214- });
215- }
216- }
217-
218153String elementText (n) {
219154 hasNodes (n) {
220155 var children = DOM .childNodes (n);
0 commit comments