@@ -234,139 +234,6 @@ export default class Wrapper implements BaseWrapper {
234234 return new WrapperArray ( wrappers )
235235 }
236236
237- /**
238- * Checks if wrapper has an attribute with matching value
239- */
240- hasAttribute ( attribute : string , value : string ) : boolean {
241- warn (
242- `hasAttribute() has been deprecated and will be ` +
243- `removed in version 1.0.0. Use attributes() ` +
244- `instead—https://vue-test-utils.vuejs.org/api/wrapper/attributes.html`
245- )
246-
247- if ( typeof attribute !== 'string' ) {
248- throwError (
249- `wrapper.hasAttribute() must be passed attribute as a string`
250- )
251- }
252-
253- if ( typeof value !== 'string' ) {
254- throwError (
255- `wrapper.hasAttribute() must be passed value as a string`
256- )
257- }
258-
259- return ! ! ( this . element . getAttribute ( attribute ) === value )
260- }
261-
262- /**
263- * Asserts wrapper has a class name
264- */
265- hasClass ( className : string ) : boolean {
266- warn (
267- `hasClass() has been deprecated and will be removed ` +
268- `in version 1.0.0. Use classes() ` +
269- `instead—https://vue-test-utils.vuejs.org/api/wrapper/classes.html`
270- )
271- let targetClass = className
272-
273- if ( typeof targetClass !== 'string' ) {
274- throwError ( 'wrapper.hasClass() must be passed a string' )
275- }
276-
277- // if $style is available and has a matching target, use that instead.
278- if ( this . vm && this . vm . $style && this . vm . $style [ targetClass ] ) {
279- targetClass = this . vm . $style [ targetClass ]
280- }
281-
282- const containsAllClasses = targetClass
283- . split ( ' ' )
284- . every ( target => this . element . classList . contains ( target ) )
285-
286- return ! ! ( this . element && containsAllClasses )
287- }
288-
289- /**
290- * Asserts wrapper has a prop name
291- */
292- hasProp ( prop : string , value : string ) : boolean {
293- warn (
294- `hasProp() has been deprecated and will be removed ` +
295- `in version 1.0.0. Use props() ` +
296- `instead—https://vue-test-utils.vuejs.org/api/wrapper/props.html`
297- )
298-
299- if ( ! this . isVueInstance ( ) ) {
300- throwError ( 'wrapper.hasProp() must be called on a Vue instance' )
301- }
302- if ( typeof prop !== 'string' ) {
303- throwError ( 'wrapper.hasProp() must be passed prop as a string' )
304- }
305-
306- // $props object does not exist in Vue 2.1.x, so use
307- // $options.propsData instead
308- if (
309- this . vm &&
310- this . vm . $options &&
311- this . vm . $options . propsData &&
312- this . vm . $options . propsData [ prop ] === value
313- ) {
314- return true
315- }
316-
317- return ! ! this . vm && ! ! this . vm . $props && this . vm . $props [ prop ] === value
318- }
319-
320- /**
321- * Checks if wrapper has a style with value
322- */
323- hasStyle ( style : string , value : string ) : boolean {
324- warn (
325- `hasStyle() has been deprecated and will be removed ` +
326- `in version 1.0.0. Use wrapper.element.style ` +
327- `instead`
328- )
329-
330- if ( typeof style !== 'string' ) {
331- throwError ( `wrapper.hasStyle() must be passed style as a string` )
332- }
333-
334- if ( typeof value !== 'string' ) {
335- throwError ( 'wrapper.hasClass() must be passed value as string' )
336- }
337-
338- /* istanbul ignore next */
339- if (
340- navigator . userAgent . includes &&
341- ( navigator . userAgent . includes ( 'node.js' ) ||
342- navigator . userAgent . includes ( 'jsdom' ) )
343- ) {
344- warn (
345- `wrapper.hasStyle is not fully supported when ` +
346- `running jsdom - only inline styles are supported`
347- )
348- }
349- const body = document . querySelector ( 'body' )
350- const mockElement = document . createElement ( 'div' )
351-
352- if ( ! ( body instanceof Element ) ) {
353- return false
354- }
355- const mockNode = body . insertBefore ( mockElement , null )
356- // $FlowIgnore : Flow thinks style[style] returns a number
357- mockElement . style [ style ] = value
358-
359- if ( ! this . options . attachedToDocument && ( this . vm || this . vnode ) ) {
360- // $FlowIgnore : Possible null value, will be removed in 1.0.0
361- const vm = this . vm || this . vnode . context . $root
362- body . insertBefore ( vm . $root . _vnode . elm , null )
363- }
364-
365- const elStyle = window . getComputedStyle ( this . element ) [ style ]
366- const mockNodeStyle = window . getComputedStyle ( mockNode ) [ style ]
367- return ! ! ( elStyle && mockNodeStyle && elStyle === mockNodeStyle )
368- }
369-
370237 /**
371238 * Returns HTML of element as a string
372239 */
@@ -562,79 +429,6 @@ export default class Wrapper implements BaseWrapper {
562429 throwError ( `wrapper.setSelected() cannot be called on this element` )
563430 }
564431
565- /**
566- * Sets vm computed
567- */
568- setComputed ( computed : Object ) : void {
569- if ( ! this . isVueInstance ( ) ) {
570- throwError (
571- `wrapper.setComputed() can only be called on a Vue ` +
572- `instance`
573- )
574- }
575-
576- warn (
577- `setComputed() has been deprecated and will be ` +
578- `removed in version 1.0.0. You can overwrite ` +
579- `computed properties by passing a computed object ` +
580- `in the mounting options`
581- )
582-
583- Object . keys ( computed ) . forEach ( key => {
584- if ( VUE_VERSION > 2.1 ) {
585- // $FlowIgnore : Problem with possibly null this.vm
586- if ( ! this . vm . _computedWatchers [ key ] ) {
587- throwError (
588- `wrapper.setComputed() was passed a value that ` +
589- `does not exist as a computed property on the ` +
590- `Vue instance. Property ${ key } does not exist ` +
591- `on the Vue instance`
592- )
593- }
594- // $FlowIgnore : Problem with possibly null this.vm
595- this . vm . _computedWatchers [ key ] . value = computed [ key ]
596- // $FlowIgnore : Problem with possibly null this.vm
597- this . vm . _computedWatchers [ key ] . getter = ( ) => computed [ key ]
598- } else {
599- let isStore = false
600- // $FlowIgnore : Problem with possibly null this.vm
601- this . vm . _watchers . forEach ( watcher => {
602- if ( watcher . getter . vuex && key in watcher . vm . $options . store . getters ) {
603- watcher . vm . $options . store . getters = {
604- ...watcher . vm . $options . store . getters
605- }
606- Object . defineProperty ( watcher . vm . $options . store . getters , key , {
607- get : function ( ) {
608- return computed [ key ]
609- }
610- } )
611- isStore = true
612- }
613- } )
614-
615- // $FlowIgnore : Problem with possibly null this.vm
616- if ( ! isStore && ! this . vm . _watchers . some ( w => w . getter . name === key ) ) {
617- throwError (
618- `wrapper.setComputed() was passed a value that does ` +
619- `not exist as a computed property on the Vue instance. ` +
620- `Property ${ key } does not exist on the Vue instance`
621- )
622- }
623- // $FlowIgnore : Problem with possibly null this.vm
624- this . vm . _watchers . forEach ( watcher => {
625- if ( watcher . getter . name === key ) {
626- watcher . value = computed [ key ]
627- watcher . getter = ( ) => computed [ key ]
628- }
629- } )
630- }
631- } )
632- // $FlowIgnore : Problem with possibly null this.vm
633- this . vm . _watchers . forEach ( watcher => {
634- watcher . run ( )
635- } )
636- }
637-
638432 /**
639433 * Sets vm data
640434 */
@@ -830,28 +624,4 @@ export default class Wrapper implements BaseWrapper {
830624 `updates are now synchronous by default`
831625 )
832626 }
833-
834- /**
835- * Utility to check wrapper is visible. Returns false if a parent
836- * element has display: none or visibility: hidden style.
837- */
838- visible ( ) : boolean {
839- warn (
840- `visible has been deprecated and will be removed in ` +
841- `version 1, use isVisible instead`
842- )
843- let element = this . element
844- while ( element ) {
845- if (
846- element . style &&
847- ( element . style . visibility === 'hidden' ||
848- element . style . display === 'none' )
849- ) {
850- return false
851- }
852- element = element . parentElement
853- }
854-
855- return true
856- }
857627}
0 commit comments