-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
83 lines (76 loc) · 2.2 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const assert = require('assert')
const {
VOID_SVG_TAGS_LIST,
VOID_HTML_TAGS_LIST,
HTML_TAGS_LIST,
SVG_TAGS_LIST,
isVoid,
isHtml,
isSvg,
isCustom,
isBoolAttribute,
hasValueAttribute
} = require('./')
describe('dom-nodes', function() {
describe('Lists', () => {
it('All the list are properly exported', () => {
assert(Array.isArray(VOID_SVG_TAGS_LIST), 'void svg tags are arrays')
assert(Array.isArray(VOID_HTML_TAGS_LIST), 'void html tags are arrays')
assert(Array.isArray(HTML_TAGS_LIST), 'html tags are arrays')
assert(Array.isArray(SVG_TAGS_LIST), 'svg tags are arrays')
})
})
describe('Helpers', () => {
it('isVoid()', () => {
assert(isVoid('img'))
assert(isVoid('circle'))
assert(isVoid('IMG'))
assert(isVoid('Img'))
assert(!isVoid('g'))
assert(!isVoid('div'))
})
it('isHtml()', () => {
assert(isHtml('img'))
assert(isHtml('div'))
assert(isHtml('DIV'))
assert(isHtml('Div'))
assert(!isHtml('circle'))
assert(!isHtml('bar'))
})
it('isSvg()', () => {
assert(isSvg('g'))
assert(isSvg('circle'))
assert(isSvg('Circle'))
assert(isSvg('radialGradient'))
assert(isSvg('radialgradient'))
assert(!isSvg('div'))
assert(!isSvg('img'))
})
it('isCustom()', () => {
assert(isCustom('user'))
assert(isCustom('my-component'))
assert(isCustom('my-Component'))
assert(!isCustom('div'))
assert(!isCustom('Div'))
assert(!isCustom('circle'))
})
it('isBoolAttribute()', () => {
assert(isBoolAttribute('selected'))
assert(isBoolAttribute('autofocus'))
assert(isBoolAttribute('loop'))
assert(!isBoolAttribute('class'))
assert(!isBoolAttribute('id'))
assert(!isBoolAttribute('src'))
})
it('hasValueAttribute()', () => {
assert(hasValueAttribute('input'))
assert(hasValueAttribute('textarea'))
assert(hasValueAttribute('select'))
assert(hasValueAttribute('progress'))
assert(hasValueAttribute('meter'))
assert(!hasValueAttribute('div'))
assert(!hasValueAttribute('ul'))
assert(!hasValueAttribute('my-component'))
})
})
})