diff --git a/lib/circuit.js b/lib/circuit.js index ebbdf398..a6ca3715 100644 --- a/lib/circuit.js +++ b/lib/circuit.js @@ -86,12 +86,14 @@ class CircuitBreaker extends EventEmitter { this.options.rollingCountBuckets = options.rollingCountBuckets || 10; this.options.rollingPercentilesEnabled = options.rollingPercentilesEnabled !== false; - this.options.capacity = Number.isInteger(options.capacity) ? options.capacity : Number.MAX_SAFE_INTEGER; + this.options.capacity = Number.isInteger(options.capacity) + ? options.capacity : Number.MAX_SAFE_INTEGER; this.options.errorFilter = options.errorFilter || (_ => false); this.semaphore = new Semaphore(this.options.capacity); - this[VOLUME_THRESHOLD] = Number.isInteger(options.volumeThreshold) ? options.volumeThreshold : 0; + this[VOLUME_THRESHOLD] = Number.isInteger(options.volumeThreshold) + ? options.volumeThreshold : 0; this[WARMING_UP] = options.allowWarmUp === true; this[STATUS] = new Status(this.options); this[STATE] = CLOSED; diff --git a/test/circuit-shutdown-test.js b/test/circuit-shutdown-test.js index 613dc0da..5027c4be 100644 --- a/test/circuit-shutdown-test.js +++ b/test/circuit-shutdown-test.js @@ -17,11 +17,17 @@ test('EventEmitter max listeners', t => { }); test('Circuit shuts down properly', t => { - t.plan(3); + t.plan(5); const breaker = circuit(passFail); t.ok(breaker.fire(1), 'breaker is active'); breaker.shutdown(); t.ok(breaker.isShutdown, 'breaker is shutdown'); t.notOk(breaker.enabled, 'breaker has been disabled'); - t.end(); + breaker.fire(1) + .then(t.fail) + .catch(err => { + t.equals('ESHUTDOWN', err.code); + t.equals('The circuit has been shutdown.', err.message); + t.end(); + }); });