From 84a9b45543f47f1fd6b4a7bba6316f67d472b04d Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 17 Mar 2014 15:50:24 -0700 Subject: [PATCH] chore(log): add `log.empty()` method to the testing logger `log.empty()` is the same as `log.reset()`, except thati `empty()` also returns the current array with messages instead of: ``` // do work expect(log).toEqual(['bar']); log.reset(); ``` do: ``` // do work expect(log.empty()).toEqual(['bar']); ``` --- test/helpers/testabilityPatch.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/helpers/testabilityPatch.js b/test/helpers/testabilityPatch.js index f61be4eeb13f..34b6b78a0141 100644 --- a/test/helpers/testabilityPatch.js +++ b/test/helpers/testabilityPatch.js @@ -269,21 +269,27 @@ function provideLog($provide) { log.toString = function() { return messages.join('; '); - } + }; log.toArray = function() { return messages; - } + }; log.reset = function() { messages = []; + }; + + log.empty = function() { + var currentMessages = messages; + messages = []; + return currentMessages; } log.fn = function(msg) { return function() { log(msg); - } - } + }; + }; log.$$log = true;