/
test.js
26 lines (23 loc) · 1.07 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
var tape = require('tape')
var type = require('./')
tape('stringifies', function (t) {
t.same(type.stringify('http', 'tcp'), '_http._tcp')
t.same(type.stringify('http', 'tcp', 'sub'), '_http._tcp._sub')
t.same(type.stringify('http', 'tcp', 'sub', 'sub2'), '_http._tcp._sub._sub2')
t.same(type.stringify('http', 'tcp', ['sub', 'sub2']), '_http._tcp._sub._sub2')
t.same(type.stringify({name: 'http', protocol: 'tcp', subtypes: ['sub', 'sub2']}), '_http._tcp._sub._sub2')
t.end()
})
tape('parses', function (t) {
t.same(type.parse('_http._tcp'), {name: 'http', protocol: 'tcp', subtypes: []})
t.same(type.parse('_http._tcp._sub'), {name: 'http', protocol: 'tcp', subtypes: ['sub']})
t.same(type.parse('_http._tcp._sub._sub2'), {name: 'http', protocol: 'tcp', subtypes: ['sub', 'sub2']})
t.end()
})
tape('shorthands', function (t) {
t.same(type.tcp('http'), '_http._tcp')
t.same(type.tcp('http', 'sub'), '_http._tcp._sub')
t.same(type.tcp('http', 'sub', 'sub2'), '_http._tcp._sub._sub2')
t.same(type.tcp('http', ['sub', 'sub2']), '_http._tcp._sub._sub2')
t.end()
})