'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
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()
})