Skip to content

Commit 0e0c94d

Browse files
committed
refactor: add deprecation warnings to hasClass, hasAttribute, and hasProp
1 parent bc41361 commit 0e0c94d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/wrappers/wrapper.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import findVNodesByRef from '../lib/find-vnodes-by-ref'
88
import VueWrapper from './vue-wrapper'
99
import WrapperArray from './wrapper-array'
1010
import ErrorWrapper from './error-wrapper'
11-
import { throwError } from '../lib/util'
11+
import { throwError, warn } from '../lib/util'
1212

1313
export default class Wrapper implements BaseWrapper {
1414
vnode: VNode;
@@ -129,6 +129,8 @@ export default class Wrapper implements BaseWrapper {
129129
* Checks if wrapper has an attribute with matching value
130130
*/
131131
hasAttribute (attribute: string, value: string) {
132+
warn('hasAttribute() has been deprecated and will be removed in version 1.0.0. Use attributes() instead—https://vue-test-utils.vuejs.org/en/api/wrapper/attributes')
133+
132134
if (typeof attribute !== 'string') {
133135
throwError('wrapper.hasAttribute() must be passed attribute as a string')
134136
}
@@ -144,6 +146,7 @@ export default class Wrapper implements BaseWrapper {
144146
* Asserts wrapper has a class name
145147
*/
146148
hasClass (className: string) {
149+
warn('hasClass() has been deprecated and will be removed in version 1.0.0. Use classes() instead—https://vue-test-utils.vuejs.org/en/api/wrapper/classes')
147150
let targetClass = className
148151

149152
if (typeof targetClass !== 'string') {
@@ -166,6 +169,8 @@ export default class Wrapper implements BaseWrapper {
166169
* Asserts wrapper has a prop name
167170
*/
168171
hasProp (prop: string, value: string) {
172+
warn('hasProp() has been deprecated and will be removed in version 1.0.0. Use props() instead—https://vue-test-utils.vuejs.org/en/api/wrapper/props')
173+
169174
if (!this.isVueComponent) {
170175
throwError('wrapper.hasProp() must be called on a Vue instance')
171176
}

0 commit comments

Comments
 (0)