aboutsummaryrefslogtreecommitdiffstats
path: root/test/testabilityPatch.js
diff options
context:
space:
mode:
authorIgor Minar2011-12-15 01:10:09 -0800
committerIgor Minar2012-01-23 22:33:28 -0800
commited78f0d830b22eb8f280e841cde6287b678fc914 (patch)
tree4f7fbc6147126d349f7b5f585adcd6378bbd6ab1 /test/testabilityPatch.js
parentdbffbefb7cd7af2ac063c95378a035aa9fbbd2ff (diff)
downloadangular.js-ed78f0d830b22eb8f280e841cde6287b678fc914.tar.bz2
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
Diffstat (limited to 'test/testabilityPatch.js')
-rw-r--r--test/testabilityPatch.js32
1 files changed, 32 insertions, 0 deletions
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;
+ });
+}