Skip to content

Commit

Permalink
starting the addition of tests - part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
lholmquist committed Apr 24, 2017
1 parent 5ef3572 commit 3130e7c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,27 @@ test('options.maxFailures should be deprecated', (t) => {
cb(passFail, options);
});

test('rolling percentile enabled option defaults to true', (t) => {
const breaker = cb(passFail);
t.equals(breaker.status.rollingPercentilesEnabled, true, 'rollingPercentilesEnabled should default to true');
t.equals(breaker.status.stats.latencyMean, 0, 'latencyMean is starts at 0 when rollingPercentilesEnabled is true');
[0.0, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.995, 1].forEach((p) => {
t.equals(breaker.status.stats.percentiles[p], 0, `${p} percentile should be 0 at the start`);
});
t.end();
});

test('rolling percentile enabled option set to false', (t) => {
const options = { rollingPercentilesEnabled: false };
const breaker = cb(passFail, options);
t.equals(breaker.status.rollingPercentilesEnabled, false, 'rollingPercentilesEnabled set to false');
t.equals(breaker.status.stats.latencyMean, -1, 'latencyMean is -1 when rollingPercentilesEnabled is false');
[0.0, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.995, 1].forEach((p) => {
t.equals(breaker.status.stats.percentiles[p], -1, `${p} percentile should be -1 when rollingPercentilesEnabled is false`);
});
t.end();
});

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

0 comments on commit 3130e7c

Please sign in to comment.