-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
44 lines (31 loc) · 918 Bytes
/
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
'use strict'
const test = require('tape')
const plugin = require('.')
test('no tags', function (t) {
const processor = plugin()
const metric = { tags: {} }
processor.process(metric)
t.same(metric.tags, {})
t.end()
})
test('overwrites tags', function (t) {
const processor = plugin({ beep: 'new' })
const metric = { tags: { beep: 'existing' } }
processor.process(metric)
t.same(metric.tags, { beep: 'new' })
t.end()
})
test('sets nullish values to undefined', function (t) {
const processor = plugin({ a: null, b: undefined })
const metric = { tags: { a: 'existing' } }
processor.process(metric)
t.same(metric.tags, { a: undefined, b: undefined })
t.end()
})
test('coerces values to strings', function (t) {
const processor = plugin({ a: 123, b: false })
const metric = { tags: {} }
processor.process(metric)
t.same(metric.tags, { a: '123', b: 'false' })
t.end()
})