Skip to content

Commit 93ea86a

Browse files
committed
add quantile and bucket tests
1 parent c418fbb commit 93ea86a

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

test/histogram.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,23 @@ tap.test(
249249
clock.uninstall();
250250
},
251251
);
252+
253+
tap.test('histogram() - buckets option', t => {
254+
const histogram = new Histogram({
255+
name: 'valid_name',
256+
description: 'Valid description',
257+
buckets: [0.001, 0.01, 0.1, 1, 10, 100, 1000],
258+
});
259+
260+
histogram.on('metric', metric => {
261+
t.equal(metric.name, 'valid_name');
262+
t.equal(metric.description, 'Valid description');
263+
t.equal(metric.type, 5);
264+
t.equal(metric.value, 1);
265+
t.same(metric.labels, []);
266+
t.same(metric.meta, { buckets: [0.001, 0.01, 0.1, 1, 10, 100, 1000] });
267+
t.end();
268+
});
269+
270+
histogram.observe(1);
271+
});

test/summary.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,25 @@ tap.test(
240240
clock.uninstall();
241241
},
242242
);
243+
244+
tap.test('summary() - buckets option', t => {
245+
const summary = new Summary({
246+
name: 'valid_name',
247+
description: 'Valid description',
248+
quantiles: [0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999],
249+
});
250+
251+
summary.on('metric', metric => {
252+
t.equal(metric.name, 'valid_name');
253+
t.equal(metric.description, 'Valid description');
254+
t.equal(metric.type, 7);
255+
t.equal(metric.value, 1);
256+
t.same(metric.labels, []);
257+
t.same(metric.meta, {
258+
quantiles: [0.001, 0.01, 0.1, 0.5, 0.9, 0.99, 0.999],
259+
});
260+
t.end();
261+
});
262+
263+
summary.observe(1);
264+
});

0 commit comments

Comments
 (0)