-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
59 lines (38 loc) · 1.35 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const assert = require('assert');
const config = {
host: "statsd.hostedgraphite.com",
port: "8125",
prefix: "958d43fb-9672-49d6-8d0b-f2aeb1bcaa8c"
};
const options = {
hostname: 'local.machine',
app: 'api',
env: process.env.NODE_ENV || 'dev',
clean: 'cmd_server'
};
describe('statsd namespacing', function () {
it("should parse simple with no options", function(){
const statsd = require('./')(config);
const expected = '.dev.app.airasoul_inc.localhost';
statsd.increment('airasoul_inc');
assert.equal(statsd.key(), expected);
});
it("should parse simple with options", function(){
const statsd = require('./')(config, options);
const expected = '.dev.api.airasoul_inc.local_machine';
statsd.increment('airasoul_inc');
assert.equal(statsd.key(), expected);
});
it("should parse and then replace a string", function(){
const statsd = require('./')(config, options);
const expected = '.dev.api.airasoul_inc.local_machine';
statsd.increment('airasoul_inc.cmd.server');
assert.equal(statsd.key(), expected);
});
it("should parse and remove unwanted chars", function(){
const statsd = require('./')(config, options);
const expected = '.dev.api.airasoul_inc.local_machine';
statsd.increment('£#airasoul_inc:cmd.server?/');
assert.equal(statsd.key(), expected);
});
});