Skip to content

Commit 06b0bb6

Browse files
authored
Use new promise interface in module tests (#142)
In #125, we switched the default aync interface to promises/async/await, but missed updating the module-level tests. This updates them.
1 parent 950765c commit 06b0bb6

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

test/module_tests.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,45 @@ describe('datadog-metrics', function() {
2222
logger.gauge('test.gauge', 23);
2323
});
2424

25-
it('should let me configure a shared metrics logger instance', function(done) {
25+
it('should let me configure a shared metrics logger instance', async function() {
2626
metrics.init.should.be.a('function');
2727
metrics.init({
2828
flushIntervalSeconds: 0,
2929
reporter: {
30-
report (series, onSuccess, _onError) {
30+
async report (series) {
3131
series.should.have.lengthOf(12); // 3 + 9 for the histogram.
3232
series[0].should.have.nested.property('points[0][1]', 23);
3333
series[0].should.have.property('metric', 'test.gauge');
3434
series[0].tags.should.have.lengthOf(0);
35-
onSuccess && onSuccess();
36-
done();
3735
}
3836
}
3937
});
4038
metrics.gauge('test.gauge', 23);
4139
metrics.increment('test.counter');
4240
metrics.increment('test.counter', 23);
4341
metrics.histogram('test.histogram', 23);
44-
metrics.flush();
42+
await metrics.flush();
4543
});
4644

47-
it('should report gauges with the same name but different tags separately', function(done) {
45+
it('should report gauges with the same name but different tags separately', async function() {
4846
metrics.init.should.be.a('function');
4947
metrics.init({
5048
flushIntervalSeconds: 0,
5149
reporter: {
52-
report (series, onSuccess, _onError) {
50+
async report (series) {
5351
series.should.have.lengthOf(2);
5452
series[0].should.have.nested.property('points[0][1]', 1);
5553
series[0].should.have.property('metric', 'test.gauge');
5654
series[0].should.have.deep.property('tags', ['tag1']);
5755
series[1].should.have.nested.property('points[0][1]', 2);
5856
series[1].should.have.property('metric', 'test.gauge');
5957
series[1].should.have.deep.property('tags', ['tag2']);
60-
onSuccess && onSuccess();
61-
done();
6258
}
6359
}
6460
});
6561
metrics.gauge('test.gauge', 1, ['tag1']);
6662
metrics.gauge('test.gauge', 2, ['tag2']);
67-
metrics.flush();
63+
await metrics.flush();
6864
});
6965

7066
it('should lazily provide a shared metrics logger instance', function() {

0 commit comments

Comments
 (0)