From ed78f0d830b22eb8f280e841cde6287b678fc914 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Thu, 15 Dec 2011 01:10:09 -0800 Subject: chore(log): generic test log service with custom toEquals matcher - any test that needs a logger can just inject provideLog - logger has susict api that makes tests more readable - custom toEquals matcher allows for pretty expectations --- test/testabilityPatch.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/testabilityPatch.js') diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index b4d11f3a..3615e3e1 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; + }); +} -- cgit v1.2.3