Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

throw meaningful message if signal does not exist

  • Loading branch information...
commit 2effdfde48809b7758b35165e0b8509f4e67f5d4 1 parent c55a09e
@AdamNowotny authored
Showing with 14 additions and 3 deletions.
  1. +11 −1 spec/signalLoggerSpec.js
  2. +3 −2 src/SignalLogger.js
View
12 spec/signalLoggerSpec.js
@@ -5,7 +5,17 @@ define(['src/SignalLogger', 'signals'], function (SignalLogger, signals) {
it('should fail if configuration not specified', function () {
expect(function () {
return new SignalLogger();
- }).toThrow({ name: 'ArgumentError' });
+ }).toThrow('Logger configuration not specified');
+ });
+
+ it('should fail if signal does not exist', function () {
+ var obj = {};
+
+ expect(function () {
+ return new SignalLogger({
+ finished: obj.finished
+ });
+ }).toThrow('Signal does not exist: finished');
});
it('should count signals', function () {
View
5 src/SignalLogger.js
@@ -1,7 +1,7 @@
define(['signals'], function () {
var SignalLogger = function (signalSpec) {
- if (signalSpec == null) throw { name: 'ArgumentError' };
+ if (signalSpec == null) throw 'Logger configuration not specified';
this.signalSpec = signalSpec;
var that = this;
initialize();
@@ -22,6 +22,7 @@
};
var SignalInfo = function (signalName, signal) {
+ if (signal == null) throw 'Signal does not exist: ' + signalName;
this.name = signalName;
this.signal = signal;
this.count = 0;
@@ -56,7 +57,7 @@
SignalInfo.prototype.matchValues = function () {
var expectedArgs = arguments;
- this.filter = function() {
+ this.filter = function () {
for (var i = 0; i < expectedArgs.length; i++) {
if (arguments[i] !== expectedArgs[i]) {
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.