forked from vuejs/vue
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathappend.spec.js
47 lines (41 loc) · 2.15 KB
/
append.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
import { compile } from '../../../packages/weex-template-compiler'
import { strToRegExp } from '../helpers/index'
describe('append props', () => {
it('add append="tree" on <cell>', () => {
const { render, staticRenderFns, errors } = compile(`<list><cell></cell></list>`)
expect(render).not.toBeUndefined()
expect(staticRenderFns).not.toBeUndefined()
expect(staticRenderFns.length).toEqual(1)
expect(staticRenderFns).toMatch(strToRegExp(`appendAsTree:true`))
expect(staticRenderFns).toMatch(strToRegExp(`attrs:{"append":"tree"}`))
expect(errors).toEqual([])
})
it('override append="node" on <cell>', () => {
const { render, staticRenderFns, errors } = compile(`<list><cell append="node"></cell></list>`)
expect(render + staticRenderFns).toMatch(strToRegExp(`attrs:{"append":"node"}`))
expect(errors).toEqual([])
})
it('add append="tree" on <header>', () => {
const { render, staticRenderFns, errors } = compile(`<list><header></header></list>`)
expect(render + staticRenderFns).toMatch(strToRegExp(`appendAsTree:true`))
expect(render + staticRenderFns).toMatch(strToRegExp(`attrs:{"append":"tree"}`))
expect(errors).toEqual([])
})
it('add append="tree" on <recycle-list>', () => {
const { render, staticRenderFns, errors } = compile(`<recycle-list for="item in list"><div></div></recycle-list>`)
expect(render + staticRenderFns).toMatch(strToRegExp(`appendAsTree:true`))
expect(render + staticRenderFns).toMatch(strToRegExp(`"append":"tree"`))
expect(errors).toEqual([])
})
it('add append="tree" on <cell-slot>', () => {
const { render, staticRenderFns, errors } = compile(`<list><cell-slot></cell-slot></list>`)
expect(render + staticRenderFns).toMatch(strToRegExp(`appendAsTree:true`))
expect(render + staticRenderFns).toMatch(strToRegExp(`attrs:{"append":"tree"}`))
expect(errors).toEqual([])
})
it('override append="node" on <cell-slot>', () => {
const { render, staticRenderFns, errors } = compile(`<list><cell-slot append="node"></cell-slot></list>`)
expect(render + staticRenderFns).toMatch(strToRegExp(`attrs:{"append":"node"}`))
expect(errors).toEqual([])
})
})