aboutsummaryrefslogtreecommitdiffstats
path: root/test/matchers.js
diff options
context:
space:
mode:
authorIgor Minar2011-11-08 01:56:42 -0800
committerIgor Minar2011-11-30 14:49:03 -0500
commit1cdfa3b9601c199ec0b45096b38e26350eca744f (patch)
treec6b87d6a8cdbcd7e65a1bbad304df25e993b8568 /test/matchers.js
parent16363d8000a484b428a16eb07d8bd0f19c4b4337 (diff)
downloadangular.js-1cdfa3b9601c199ec0b45096b38e26350eca744f.tar.bz2
feat(deferreds/promises): Q-like deferred/promise implementation with a ton of specs
Diffstat (limited to 'test/matchers.js')
-rw-r--r--test/matchers.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/matchers.js b/test/matchers.js
index 9cd582e1..1e0ae92a 100644
--- a/test/matchers.js
+++ b/test/matchers.js
@@ -89,6 +89,44 @@ beforeEach(function() {
},
+ toHaveBeenCalledOnceWith: function() {
+ var expectedArgs = jasmine.util.argsToArray(arguments);
+
+ if (!jasmine.isSpy(this.actual)) {
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ }
+
+ this.message = function() {
+ if (this.actual.callCount != 1) {
+ if (this.actual.callCount == 0) {
+ return [
+ 'Expected spy ' + this.actual.identity + ' to have been called with ' +
+ jasmine.pp(expectedArgs) + ' but it was never called.',
+ 'Expected spy ' + this.actual.identity + ' not to have been called with ' +
+ jasmine.pp(expectedArgs) + ' but it was.'
+ ];
+ }
+
+ return [
+ 'Expected spy ' + this.actual.identity + ' to have been called with ' +
+ jasmine.pp(expectedArgs) + ' but it was never called.',
+ 'Expected spy ' + this.actual.identity + ' not to have been called with ' +
+ jasmine.pp(expectedArgs) + ' but it was.'
+ ];
+ } else {
+ return [
+ 'Expected spy ' + this.actual.identity + ' to have been called with ' +
+ jasmine.pp(expectedArgs) + ' but was called with ' + jasmine.pp(this.actual.argsForCall),
+ 'Expected spy ' + this.actual.identity + ' not to have been called with ' +
+ jasmine.pp(expectedArgs) + ' but was called with ' + jasmine.pp(this.actual.argsForCall)
+ ];
+ }
+ };
+
+ return this.actual.callCount === 1 && this.env.contains_(this.actual.argsForCall, expectedArgs);
+ },
+
+
toBeOneOf: function() {
return indexOf(arguments, this.actual) !== -1;
},