@@ -9,18 +9,18 @@ import ComponentWithoutName from '~resources/components/component-without-name.v
9
9
import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue'
10
10
import RecursiveComponent from '~resources/components/recursive-component.vue'
11
11
import { vueVersion } from '~resources/utils'
12
- import { describeRunIf } from 'conditional-specs'
12
+ import { describeRunIf , itDoNotRunIf } from 'conditional-specs'
13
13
14
14
describeRunIf ( process . env . TEST_ENV !== 'node' ,
15
15
'shallowMount' , ( ) => {
16
- let info
17
-
18
16
beforeEach ( ( ) => {
19
- info = sinon . stub ( console , 'info' )
17
+ sinon . stub ( console , 'info' )
18
+ sinon . stub ( console , 'error' )
20
19
} )
21
20
22
21
afterEach ( ( ) => {
23
- info . restore ( )
22
+ console . info . restore ( )
23
+ console . error . restore ( )
24
24
} )
25
25
26
26
it ( 'returns new VueWrapper of Vue localVue if no options are passed' , ( ) => {
@@ -61,7 +61,7 @@ describeRunIf(process.env.TEST_ENV !== 'node',
61
61
localVue . component ( 'registered-component' , ComponentWithLifecycleHooks )
62
62
mount ( TestComponent , { localVue } )
63
63
64
- expect ( info . callCount ) . to . equal ( 4 )
64
+ expect ( console . info . callCount ) . to . equal ( 4 )
65
65
} )
66
66
67
67
it ( 'stubs globally registered components' , ( ) => {
@@ -72,12 +72,52 @@ describeRunIf(process.env.TEST_ENV !== 'node',
72
72
shallowMount ( Component )
73
73
mount ( Component )
74
74
75
- expect ( info . callCount ) . to . equal ( 4 )
76
- } )
75
+ expect ( console . info . callCount ) . to . equal ( 4 )
76
+ } )
77
+
78
+ itDoNotRunIf (
79
+ vueVersion < 2.1 ,
80
+ 'adds stubbed components to ignored elements' , ( ) => {
81
+ const TestComponent = {
82
+ template : `
83
+ <div>
84
+ <router-link>
85
+ </router-link>
86
+ <custom-component />
87
+ </div>
88
+ ` ,
89
+ components : {
90
+ 'router-link' : {
91
+ template : '<div/>'
92
+ } ,
93
+ 'custom-component' : {
94
+ template : '<div/>'
95
+ }
96
+ }
97
+ }
98
+ shallowMount ( TestComponent )
99
+ expect ( console . error ) . not . called
100
+ } )
101
+
102
+ itDoNotRunIf (
103
+ vueVersion < 2.1 ,
104
+ 'handles recursive components' , ( ) => {
105
+ const TestComponent = {
106
+ template : `
107
+ <div>
108
+ <test-component />
109
+ </div>
110
+ ` ,
111
+ name : 'test-component'
112
+ }
113
+ const wrapper = shallowMount ( TestComponent )
114
+ expect ( wrapper . html ( ) ) . to . contain ( '<test-component-stub>' )
115
+ expect ( console . error ) . not . called
116
+ } )
77
117
78
118
it ( 'does not call stubbed children lifecycle hooks' , ( ) => {
79
119
shallowMount ( ComponentWithNestedChildren )
80
- expect ( info . called ) . to . equal ( false )
120
+ expect ( console . info . called ) . to . equal ( false )
81
121
} )
82
122
83
123
it ( 'stubs extended components' , ( ) => {
0 commit comments