UNPKG

1.17 kBJavaScriptView Raw
1'use strict'
2
3const attribute = require('../lib/attribute')
4const { test } = require('tap')
5
6test('default', (t) => {
7 t.is(attribute('unwanted', {}), undefined)
8 t.end()
9})
10
11test('link enclosure', (t) => {
12 const key = 'link'
13 const rel = 'enclosure'
14 const href = 'http: //somewhere'
15 const attr = { rel: rel, href: href }
16 const expected = { url: href, type: undefined, length: undefined }
17 const kv = attribute(key, attr)
18
19 t.equals(kv[0], rel)
20 t.deepEquals(kv[1], expected)
21 t.end()
22})
23
24test('link payment', (t) => {
25 const key = 'link'
26 const rel = 'payment'
27 const href = 'http: //somewhere'
28 const attr = { rel: rel, href: href }
29 const kv = attribute(key, attr)
30
31 t.equals(kv[0], rel)
32 t.equals(kv[1], href)
33 t.end()
34})
35
36test('link default', (t) => {
37 const key = 'link'
38 const href = 'http: //somewhere'
39 const attr = { href: href }
40 const kv = attribute(key, attr)
41
42 t.equals(kv[0], key)
43 t.equals(kv[1], href)
44 t.end()
45})
46
47test('image', (t) => {
48 const key = 'image'
49 const href = 'http: //somewhere'
50 const attr = { href: href }
51 const kv = attribute(key, attr)
52
53 t.equals(kv[0], key)
54 t.equals(kv[1], href)
55 t.end()
56})