@@ -9,18 +9,18 @@ import ComponentWithoutName from '~resources/components/component-without-name.v
99import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue'
1010import RecursiveComponent from '~resources/components/recursive-component.vue'
1111import { vueVersion } from '~resources/utils'
12- import { describeRunIf } from 'conditional-specs'
12+ import { describeRunIf , itDoNotRunIf } from 'conditional-specs'
1313
1414describeRunIf ( process . env . TEST_ENV !== 'node' ,
1515 'shallowMount' , ( ) => {
16- let info
17-
1816 beforeEach ( ( ) => {
19- info = sinon . stub ( console , 'info' )
17+ sinon . stub ( console , 'info' )
18+ sinon . stub ( console , 'error' )
2019 } )
2120
2221 afterEach ( ( ) => {
23- info . restore ( )
22+ console . info . restore ( )
23+ console . error . restore ( )
2424 } )
2525
2626 it ( 'returns new VueWrapper of Vue localVue if no options are passed' , ( ) => {
@@ -61,7 +61,7 @@ describeRunIf(process.env.TEST_ENV !== 'node',
6161 localVue . component ( 'registered-component' , ComponentWithLifecycleHooks )
6262 mount ( TestComponent , { localVue } )
6363
64- expect ( info . callCount ) . to . equal ( 4 )
64+ expect ( console . info . callCount ) . to . equal ( 4 )
6565 } )
6666
6767 it ( 'stubs globally registered components' , ( ) => {
@@ -72,12 +72,52 @@ describeRunIf(process.env.TEST_ENV !== 'node',
7272 shallowMount ( Component )
7373 mount ( Component )
7474
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+ } )
77117
78118 it ( 'does not call stubbed children lifecycle hooks' , ( ) => {
79119 shallowMount ( ComponentWithNestedChildren )
80- expect ( info . called ) . to . equal ( false )
120+ expect ( console . info . called ) . to . equal ( false )
81121 } )
82122
83123 it ( 'stubs extended components' , ( ) => {
0 commit comments