diff --git a/test/matchers.js b/test/matchers.js index 1e0ae92a9dbf..fd706d3c11bf 100644 --- a/test/matchers.js +++ b/test/matchers.js @@ -36,6 +36,15 @@ beforeEach(function() { toBeDirty: cssMatcher('ng-dirty', 'ng-pristine'), toBePristine: cssMatcher('ng-pristine', 'ng-dirty'), + toEqual: function(expected) { + if (this.actual && this.actual.$$log) { + this.actual = (typeof expected === 'string') + ? this.actual.toString() + : this.actual.toArray(); + } + return jasmine.Matchers.prototype.toEqual.call(this, expected); + }, + toEqualData: function(expected) { return angular.equals(this.actual, expected); }, diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index b4d11f3a94f9..3615e3e147e7 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -185,3 +185,35 @@ function assertVisible(node) { } } +function provideLog($provide) { + $provide.factory('log', function() { + var messages = []; + + function log(msg) { + messages.push(msg); + return msg; + } + + log.toString = function() { + return messages.join('; '); + } + + log.toArray = function() { + return messages; + } + + log.reset = function() { + messages = []; + } + + log.fn = function(msg) { + return function() { + log(msg); + } + } + + log.$$log = true; + + return log; + }); +}