Skip to content

chore: fix typos #1533

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

Merged
merged 3 commits into from
May 6, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function nextTick(): Promise<void> {

export function warnDeprecated(method: string, fallback: string = '') {
if (!config.showDeprecationWarnings) return
let msg = `${method} is deprecated and will removed in the next major version`
let msg = `${method} is deprecated and will be removed in the next major version`
if (fallback) msg += ` ${fallback}`
warn(msg)
}
20 changes: 5 additions & 15 deletions packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default class Wrapper implements BaseWrapper {
* Calls destroy on vm
*/
destroy(): void {
if (!this.isVueInstance() && !this.isFunctionalComponent) {
if (!this.vm && !this.isFunctionalComponent) {
throwError(
`wrapper.destroy() can only be called on a Vue instance or ` +
`functional component.`
Expand All @@ -153,7 +153,7 @@ export default class Wrapper implements BaseWrapper {
this.element.parentNode.removeChild(this.element)
}

if (this.isVueInstance()) {
if (this.vm) {
// $FlowIgnore
this.vm.$destroy()
throwIfInstancesThrew(this.vm)
Expand Down Expand Up @@ -370,7 +370,7 @@ export default class Wrapper implements BaseWrapper {
*/
isVisible(): boolean {
warnDeprecated(
'isEmpty',
'isVisible',
`Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobevisible`
)
let element = this.element
Expand Down Expand Up @@ -428,7 +428,7 @@ export default class Wrapper implements BaseWrapper {
overview(): void {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overview() function uses isVisible() in L439.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind... overview is deprecated as well. I was just confused because I recently saw the function implemented for the first time

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about this deprecation?

If people find it very useful, I guess we can keep it - the idea was to thin down the API and really focus on providing a clean experience there.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently working on my first real project with Vue. Without a lot of experience, you stumble across a number of hurdles when testing. For this, the method was helpful a few times, even if it was never part of my final tests. I used it for debugging purposes.

Up to this point I would surely have done it without this method. I think to make a decision you would have to ask various other people.

Limiting the API to the bare minimum is definitely a good decision.

warnDeprecated(`overview`)

if (!this.isVueInstance()) {
if (!this.vm) {
throwError(`wrapper.overview() can only be called on a Vue instance`)
}

Expand Down Expand Up @@ -530,11 +530,6 @@ export default class Wrapper implements BaseWrapper {
* @deprecated
*/
setChecked(checked: boolean = true): Promise<*> {
warnDeprecated(
`setChecked`,
'When you migrate to VTU 2, use setValue instead.'
)

if (typeof checked !== 'boolean') {
throwError('wrapper.setChecked() must be passed a boolean')
}
Expand Down Expand Up @@ -582,11 +577,6 @@ export default class Wrapper implements BaseWrapper {
* @deprecated
*/
setSelected(): Promise<void> {
warnDeprecated(
`setSelected`,
'When you migrate to VTU 2, use setValue instead.'
)

const tagName = this.element.tagName

if (tagName === 'SELECT') {
Expand Down Expand Up @@ -642,7 +632,7 @@ export default class Wrapper implements BaseWrapper {
setMethods(methods: Object): void {
warnDeprecated(`setMethods`)

if (!this.isVueInstance()) {
if (!this.vm) {
throwError(`wrapper.setMethods() can only be called on a Vue instance`)
}
Object.keys(methods).forEach(key => {
Expand Down
2 changes: 1 addition & 1 deletion packages/test-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ export interface WrapperArray<V extends Vue> extends BaseWrapper {
}

interface WrapperOptions {
attachTo?: Element | string
attachedToDocument?: boolean
}

interface MountOptions<V extends Vue> extends ComponentOptions<V> {
attachToDocument?: boolean
attachTo?: Element | string
context?: VNodeData
localVue?: typeof Vue
mocks?: object | false
Expand Down
3 changes: 3 additions & 0 deletions packages/test-utils/types/test/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mount(ClassComponent, {
mocks: {
$store: store
},
attachTo: '#el',
parentComponent: normalOptions,
slots: {
default: `<div>Foo</div>`,
Expand Down Expand Up @@ -57,6 +58,7 @@ mount(functionalOptions, {
context: {
props: { foo: 'test' }
},
attachTo: document.createElement('div'),
stubs: ['child']
})

Expand Down Expand Up @@ -100,6 +102,7 @@ config.provide['foo'] = {
bar: {}
}
config.silent = true
config.showDeprecationWarnings = false

// Check we can use default export
VueTestUtils.config.silent = false