-
Notifications
You must be signed in to change notification settings - Fork 668
/
Copy pathattributes.spec.js
34 lines (30 loc) · 1.37 KB
/
attributes.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
import { compileToFunctions } from 'vue-template-compiler'
import { describeWithShallowAndMount } from '~resources/utils'
describeWithShallowAndMount('attributes', mountingMethod => {
it('returns true if wrapper contains attribute matching value', () => {
const attribute = 'attribute'
const value = 'value'
const compiled = compileToFunctions(`<div ${attribute}=${value}></div>`)
const wrapper = mountingMethod(compiled)
expect(wrapper.attributes()).to.eql({ attribute: value })
})
it('returns empty object if wrapper does not contain any attributes', () => {
const compiled = compileToFunctions('<div />')
const wrapper = mountingMethod(compiled)
expect(wrapper.attributes()).to.eql({})
})
it('returns the given attribute if wrapper contains attribute matching value', () => {
const attribute = 'attribute'
const value = 'value'
const compiled = compileToFunctions(`<div ${attribute}=${value}></div>`)
const wrapper = mountingMethod(compiled)
expect(wrapper.attributes('attribute')).to.eql(value)
})
it('returns undefined if the wrapper does not contain the matching value', () => {
const attribute = 'attribute'
const value = 'value'
const compiled = compileToFunctions(`<div ${attribute}=${value}></div>`)
const wrapper = mountingMethod(compiled)
expect(wrapper.attributes('fake')).to.eql(undefined)
})
})