@@ -18,6 +18,8 @@ import 'package:angular2/src/facade/collection.dart' show StringMapWrapper;
1818import './test_injector.dart' ;
1919export './test_injector.dart' show inject;
2020
21+ import 'package:collection/equality.dart' ;
22+
2123bool IS_DARTIUM = true ;
2224
2325List _testBindings = [];
@@ -76,6 +78,8 @@ Expect expect(actual, [matcher]) {
7678 return expect;
7779}
7880
81+ const _u = null ;
82+
7983class Expect extends gns.Expect {
8084 Expect (actual) : super (actual);
8185
@@ -87,7 +91,32 @@ class Expect extends gns.Expect {
8791 void toImplement (expected) => toBeA (expected);
8892 void toBeNaN () => _expect (double .NAN .compareTo (actual) == 0 , equals (true ));
8993 void toHaveText (expected) => _expect (elementText (actual), expected);
94+ void toHaveBeenCalledWith ([a = _u, b = _u, c = _u, d = _u, e = _u, f = _u]) =>
95+ _expect (_argsMatch (actual, a, b, c, d, e, f), true , reason: 'method invoked with correct arguments' );
9096 Function get _expect => gns.guinness.matchers.expect;
97+
98+ // TODO(tbosch): move this hack into Guinness
99+ _argsMatch (spyFn, [a0 = _u, a1 = _u, a2 = _u, a3 = _u, a4 = _u, a5 = _u]) {
100+ var calls = spyFn.calls;
101+ final toMatch = _takeDefined ([a0, a1, a2, a3, a4, a5]);
102+ if (calls.isEmpty) {
103+ return false ;
104+ } else {
105+ gns.SamePropsMatcher matcher = new gns.SamePropsMatcher (toMatch);
106+ for (var i= 0 ; i< calls.length; i++ ) {
107+ var call = calls[i];
108+ // TODO: create a better error message, not just 'Expected: <true> Actual: <false>'.
109+ // For hacking this is good:
110+ // print(call.positionalArguments);
111+ if (matcher.matches (call.positionalArguments, null )) {
112+ return true ;
113+ }
114+ }
115+ return false ;
116+ }
117+ }
118+
119+ List _takeDefined (List iter) => iter.takeWhile ((_) => _ != _u).toList ();
91120}
92121
93122class NotExpect extends gns.NotExpect {
0 commit comments