forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattrs.spec.js
30 lines (28 loc) · 993 Bytes
/
attrs.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
import { compileToFunctions } from 'vue-template-compiler'
import { attrsSupported } from '~resources/utils'
import {
describeWithMountingMethods,
isRunningPhantomJS
} from '~resources/utils'
import {
itSkipIf
} from 'conditional-specs'
describeWithMountingMethods('options.attrs', (mountingMethod) => {
itSkipIf(
mountingMethod.name === 'renderToString' || isRunningPhantomJS,
'handles inherit attrs', () => {
if (!attrsSupported) return
const wrapper = mountingMethod(compileToFunctions('<p :id="anAttr" />'), {
attrs: {
anAttr: 'an attribute'
}
})
expect(wrapper.vm.$attrs.anAttr).to.equal('an attribute')
expect(wrapper.vm.$attrs.anAttr).to.equal('an attribute')
})
itSkipIf(mountingMethod.name === 'renderToString',
'defines attrs as empty object even when not passed', () => {
const wrapper = mountingMethod(compileToFunctions('<p />'))
expect(wrapper.vm.$attrs).to.deep.equal({})
})
})