Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): add sync to WrapperOptions #590

Merged
merged 1 commit into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/en/api/wrapper/README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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