Skip to content

Commit

Permalink
adding in tests to test the emit with latency
Browse files Browse the repository at this point in the history
  • Loading branch information
lholmquist committed Apr 24, 2017
1 parent 3130e7c commit e61c7d7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,40 @@ test('rolling percentile enabled option set to false', (t) => {
t.end();
});

test('Circuit Breaker success event emits latency', (t) => {
t.plan(1);
const breaker = cb(passFail);
breaker.on('success', (result, latencyTime) => {
t.ok(latencyTime, 'second argument is the latency');
t.end();
});

breaker.fire(1);
});

test('Circuit Breaker timeout event emits latency', (t) => {
t.plan(1);
const breaker = cb(passFail);
breaker.on('failure', (result, latencyTime) => {
t.ok(latencyTime, 'second argument is the latency');
t.end();
});

breaker.fire(-1).catch(() => {});
});

test('Circuit Breaker failure event emits latency', (t) => {
t.plan(1);
const breaker = cb(slowFunction, { timeout: 10 });

breaker.on('timeout', (result, latencyTime) => {
t.ok(latencyTime, 'second argument is the latency');
t.end();
});

breaker.fire(-1).catch(() => {});
});

/**
* Returns a promise that resolves if the parameter
* 'x' evaluates to >= 0. Otherwise the returned promise fails.
Expand Down

0 comments on commit e61c7d7

Please sign in to comment.