Skip to content

Commit

Permalink
fix(types): add sync to WrapperOptions (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
38elements authored and eddyerburgh committed May 7, 2018
1 parent 31202ab commit 570d80d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/en/api/wrapper/README.md
Expand Up @@ -9,7 +9,8 @@ A `Wrapper` is an object that contains a mounted component or vnode and methods
`vm` `Component`: this is the `Vue` instance. You can access all the [instance methods and properties of a vm](https://vuejs.org/v2/api/#Instance-Properties) with `wrapper.vm`. This only exists on Vue component wrappers
`element` `HTMLElement`: the root DOM node of the wrapper
`options` `Object`: Object containing Vue Test Utils options passed to `mount` or `shallowMount`
`options.attachedToDom` `Boolean`: True if `attachToDom` was passed to `mount` or `shallowMount`
`options.attachedToDocument` `Boolean`: True if `attachedToDocument` was passed to `mount` or `shallowMount`
`options.sync` `Boolean`: True if `sync` was not passed as `false` to `mount` or `shallowMount`

- **Methods:**

Expand Down
3 changes: 1 addition & 2 deletions flow/wrapper.flow.js
Expand Up @@ -39,6 +39,5 @@ declare interface BaseWrapper { // eslint-disable-line no-undef

declare type WrapperOptions = { // eslint-disable-line no-undef
attachedToDocument: boolean,
sync: boolean,
error?: string
sync: boolean
}
1 change: 1 addition & 0 deletions packages/test-utils/types/index.d.ts
Expand Up @@ -113,6 +113,7 @@ export interface WrapperArray<V extends Vue> extends BaseWrapper {

interface WrapperOptions {
attachedToDocument: boolean
sync: boolean
}

interface MountOptions<V extends Vue> extends ComponentOptions<V> {
Expand Down
Expand Up @@ -15,6 +15,7 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => {
expect(wrapper.text()).to.equal('hello')
wrapper.vm.someData = 'world'
expect(wrapper.text()).to.equal('world')
expect(wrapper.options.sync).to.equal(true)
})

it('sets watchers to sync if undefined', () => {
Expand All @@ -29,6 +30,7 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => {
expect(wrapper.text()).to.equal('hello')
wrapper.vm.someData = 'world'
expect(wrapper.text()).to.equal('world')
expect(wrapper.options.sync).to.equal(true)
})

it('handles methods that update watchers', () => {
Expand Down Expand Up @@ -102,6 +104,7 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => {
expect(wrapper.text()).to.equal('hello')
wrapper.vm.someData = 'world'
expect(wrapper.text()).to.equal('hello')
expect(wrapper.options.sync).to.equal(false)
setTimeout(() => {
expect(wrapper.text()).to.equal('world')
done()
Expand Down

0 comments on commit 570d80d

Please sign in to comment.