Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit c5e41a0

Browse files
committed
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']); ```
1 parent 748a6c8 commit c5e41a0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/helpers/testabilityPatch.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -269,21 +269,27 @@ function provideLog($provide) {
269269

270270
log.toString = function() {
271271
return messages.join('; ');
272-
}
272+
};
273273

274274
log.toArray = function() {
275275
return messages;
276-
}
276+
};
277277

278278
log.reset = function() {
279279
messages = [];
280+
};
281+
282+
log.empty = function() {
283+
var currentMessages = messages;
284+
messages = [];
285+
return currentMessages;
280286
}
281287

282288
log.fn = function(msg) {
283289
return function() {
284290
log(msg);
285-
}
286-
}
291+
};
292+
};
287293

288294
log.$$log = true;
289295

0 commit comments

Comments
 (0)