Skip to content

Commit

Permalink
fix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
38elements committed Jun 23, 2018
1 parent 974be4f commit 994018f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions packages/test-utils/src/vue-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export default class VueWrapper extends Wrapper implements BaseWrapper {
// $FlowIgnore : issue with defineProperty
Object.defineProperty(this, 'vnode', {
get: () => vm._vnode,
set: () => throwError(`VueWrapper.vnode is read-only`)
set: () => throwError('wrapper.vnode is read-only')
})
// $FlowIgnore
Object.defineProperty(this, 'element', {
get: () => vm.$el,
set: () => throwError(`VueWrapper.element is read-only`)
set: () => throwError('wrapper.element is read-only')
})
// $FlowIgnore
Object.defineProperty(this, 'vm', {
get: () => vm,
set: () => throwError(`VueWrapper.vm is read-only`)
set: () => throwError('wrapper.vm is read-only')
})
if (options.sync) {
setWatchersToSync(vm)
Expand Down
4 changes: 2 additions & 2 deletions packages/test-utils/src/wrapper-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export default class WrapperArray implements BaseWrapper {
// $FlowIgnore
Object.defineProperty(this, 'wrappers', {
get: () => wrappers,
set: () => throwError(`WrapperArray.wrappers is read-only`)
set: () => throwError('wrapperArray.wrappers is read-only')
})
// $FlowIgnore
Object.defineProperty(this, 'length', {
get: () => length,
set: () => throwError(`WrapperArray.length is read-only`)
set: () => throwError('wrapperArray.length is read-only')
})
}

Expand Down
13 changes: 5 additions & 8 deletions packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { orderWatchers } from './order-watchers'

export default class Wrapper implements BaseWrapper {
+vnode: VNode | null;
_vnode: VNode | null;
+vm: Component | null;
_emitted: { [name: string]: Array<Array<any>> };
_emittedByOrder: Array<{ name: string, args: Array<any> }>;
Expand All @@ -40,28 +39,27 @@ export default class Wrapper implements BaseWrapper {
const element = node instanceof Element ? node : node.elm
// Prevent redefine by VueWrapper
if (this.constructor.name === 'Wrapper') {
this._vnode = vnode
// $FlowIgnore
Object.defineProperty(this, 'vnode', {
get: () => this._vnode,
set: () => throwError(`Wrapper.vnode is read-only`)
get: () => vnode,
set: () => throwError('wrapper.vnode is read-only')
})
// $FlowIgnore
Object.defineProperty(this, 'element', {
get: () => element,
set: () => throwError(`Wrapper.element is read-only`)
set: () => throwError('wrapper.element is read-only')
})
// $FlowIgnore
Object.defineProperty(this, 'vm', {
get: () => undefined,
set: () => throwError(`Wrapper.vm is read-only`)
set: () => throwError('wrapper.vm is read-only')
})
}
const frozenOptions = Object.freeze(options)
// $FlowIgnore
Object.defineProperty(this, 'options', {
get: () => frozenOptions,
set: () => throwError(`${this.constructor.name}.options is read-only`)
set: () => throwError('wrapper.options is read-only')
})
if (
this.vnode &&
Expand Down Expand Up @@ -668,7 +666,6 @@ export default class Wrapper implements BaseWrapper {
})

// $FlowIgnore : Problem with possibly null this.vm
this._vnode = this.vm._vnode
orderWatchers(this.vm || this.vnode.context.$root)
Vue.config.silent = originalConfig
}
Expand Down
2 changes: 1 addition & 1 deletion test/specs/vue-wrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describeWithShallowAndMount('VueWrapper', mountingMethod => {
it(`has the ${property} property which is read-only`, () => {
const wrapper = mountingMethod({ template: '<div><p></p></div>' })
expect(wrapper.constructor.name).to.equal('VueWrapper')
const message = `[vue-test-utils]: VueWrapper.${property} is read-only`
const message = `[vue-test-utils]: wrapper.${property} is read-only`
expect(() => { wrapper[property] = 'foo' })
.to.throw()
.with.property('message', message)
Expand Down
2 changes: 1 addition & 1 deletion test/specs/wrapper-array.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describeWithShallowAndMount('WrapperArray', mountingMethod => {
['wrappers', 'length'].forEach(property => {
it(`has the ${property} property which is read-only`, () => {
const wrapperArray = getWrapperArray()
const message = `[vue-test-utils]: WrapperArray.${property} is read-only`
const message = `[vue-test-utils]: wrapperArray.${property} is read-only`
expect(() => { wrapperArray[property] = 'foo' })
.to.throw()
.with.property('message', message)
Expand Down
2 changes: 1 addition & 1 deletion test/specs/wrapper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describeWithShallowAndMount('Wrapper', mountingMethod => {
const wrapper = mountingMethod({ template: '<div><p></p></div>' })
.find('p')
expect(wrapper.constructor.name).to.equal('Wrapper')
const message = `[vue-test-utils]: Wrapper.${property} is read-only`
const message = `[vue-test-utils]: wrapper.${property} is read-only`
expect(() => { wrapper[property] = 'foo' })
.to.throw()
.with.property('message', message)
Expand Down

0 comments on commit 994018f

Please sign in to comment.