-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.js
72 lines (39 loc) · 1.39 KB
/
spec.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
import domGen, {div} from './src'
import $ from 'jquery'
import {expect} from 'chai'
global.$ = $
describe('div()', () => {
it('creates jquery object of empty div', () => {
const elem = div({addClass: 'foo'})
expect(elem).to.be.instanceof($)
expect(elem[0].tagName).to.equal('DIV')
expect(elem.html()).to.equal('')
})
})
describe('div(opts)', () => {
it('create jquery object of div with options', () => {
const elem = div({addClass: 'foo', data: {'bar': 'baz'}})
expect(elem.hasClass('foo')).to.be.true
expect(elem.data('bar')).to.equal('baz')
})
})
describe('div(opts, param0, [param1, ...])', () => {
it('appends additional params to the element', () => {
const elem = div({}, 'foo', div({addClass: 'bar'}, 'baz'), 'spam')
expect(elem.html()).to.equal('foo<div class="bar">baz</div>spam')
})
it('can omits first param', () => {
let elem = div('foo', div('bar'), 'baz')
expect(elem.html()).to.equal('foo<div>bar</div>baz')
elem = div('foo', [div('bar'), div('baz')])
expect(elem.html()).to.equal('foo<div>bar</div><div>baz</div>')
})
})
describe('domGen("x-tag")(opts, params, ...)', () => {
it('creates the dom of custom tags', () => {
const xTag = domGen('x-tag')
const elem = xTag({addClass: 'foo'}, 'bar', div('baz'))
expect(elem).to.be.instanceof($)
expect(elem[0].tagName).to.equal('X-TAG')
})
})