1 | var tape = require('tape')
|
---|
2 | var type = require('./')
|
---|
3 |
|
---|
4 | tape('stringifies', function (t) {
|
---|
5 | t.same(type.stringify('http', 'tcp'), '_http._tcp')
|
---|
6 | t.same(type.stringify('http', 'tcp', 'sub'), '_http._tcp._sub')
|
---|
7 | t.same(type.stringify('http', 'tcp', 'sub', 'sub2'), '_http._tcp._sub._sub2')
|
---|
8 | t.same(type.stringify('http', 'tcp', ['sub', 'sub2']), '_http._tcp._sub._sub2')
|
---|
9 | t.same(type.stringify({name: 'http', protocol: 'tcp', subtypes: ['sub', 'sub2']}), '_http._tcp._sub._sub2')
|
---|
10 | t.end()
|
---|
11 | })
|
---|
12 |
|
---|
13 | tape('parses', function (t) {
|
---|
14 | t.same(type.parse('_http._tcp'), {name: 'http', protocol: 'tcp', subtypes: []})
|
---|
15 | t.same(type.parse('_http._tcp._sub'), {name: 'http', protocol: 'tcp', subtypes: ['sub']})
|
---|
16 | t.same(type.parse('_http._tcp._sub._sub2'), {name: 'http', protocol: 'tcp', subtypes: ['sub', 'sub2']})
|
---|
17 | t.end()
|
---|
18 | })
|
---|
19 |
|
---|
20 | tape('shorthands', function (t) {
|
---|
21 | t.same(type.tcp('http'), '_http._tcp')
|
---|
22 | t.same(type.tcp('http', 'sub'), '_http._tcp._sub')
|
---|
23 | t.same(type.tcp('http', 'sub', 'sub2'), '_http._tcp._sub._sub2')
|
---|
24 | t.same(type.tcp('http', ['sub', 'sub2']), '_http._tcp._sub._sub2')
|
---|
25 | t.end()
|
---|
26 | })
|
---|