Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit cd2240d

Browse files
committed
Add test for custom lynx
1 parent a58c64b commit cd2240d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/express-statsd.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var expect = require('chai').expect;
2+
var Lynx = require('lynx');
23
var expressStatsd = require('../lib/express-statsd');
34
var utils = require('./utils');
45

@@ -97,6 +98,26 @@ describe('An express server', function () {
9798
expect(this.messages[1]).to.match(/^my-key\.response_time:\d|ms$/);
9899
});
99100
});
101+
102+
describe('receiving a request with a custom lynx', function () {
103+
utils.runServer(1337, [
104+
function (req, res, next) {
105+
req.statsdKey = 'my-key';
106+
next();
107+
},
108+
expressStatsd({client: new Lynx('127.0.0.1', 8125, {scope: 'my-scope'})}),
109+
function (req, res) {
110+
res.send(200);
111+
}
112+
]);
113+
utils.saveRequest('http://localhost:1337');
114+
utils.getStatsdMessages();
115+
116+
it('should use the custom lynx client', function () {
117+
expect(this.messages[0]).to.match(/^my-scope\.my-key\.status_code\.200:\d\|c$/);
118+
expect(this.messages[1]).to.match(/^my-scope\.my-key\.response_time:\d|ms$/);
119+
});
120+
});
100121
});
101122

102123
describe('without express-statsd receiving a request', function () {

0 commit comments

Comments
 (0)