Skip to content

Commit 5e02b92

Browse files
authoredMay 5, 2018
fix: only order deps if watcher exists (#583)
* fix: only order deps if watcher exists * test: skip if scoped slots not supported * refactor: change test utils checks to consts * Update utils.js
1 parent d8485f5 commit 5e02b92

File tree

14 files changed

+50
-29
lines changed

14 files changed

+50
-29
lines changed
 

‎packages/server-test-utils/scripts/build.js

+1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ rollupOptions.forEach(options => {
5757
.then(() => success(`${options.format} build successful`))
5858
.catch((err) => {
5959
error(err)
60+
process.exit(1)
6061
})
6162
})

‎packages/test-utils/scripts/build.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,6 @@ rollupOptions.forEach(options => {
7070
.then(() => success(`${options.format} build successful`))
7171
.catch((err) => {
7272
error(err)
73+
process.exit(1)
7374
})
7475
})

‎packages/test-utils/src/order-watchers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function orderVmWatchers (vm) {
2222
})
2323
}
2424

25-
orderDeps(vm._watcher)
25+
vm._watcher && orderDeps(vm._watcher)
2626

2727
vm.$children.forEach(orderVmWatchers)
2828
}

‎test/resources/utils.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@ export const isRunningPhantomJS =
1616
navigator.userAgent.includes &&
1717
navigator.userAgent.match(/PhantomJS/i)
1818

19-
export function injectSupported () {
20-
return vueVersion > 2.2
21-
}
19+
export const injectSupported = vueVersion > 2.2
2220

23-
export function attrsSupported () {
24-
return vueVersion > 2.2
25-
}
21+
export const attrsSupported = vueVersion > 2.2
2622

27-
export function listenersSupported () {
28-
return vueVersion > 2.3
29-
}
23+
export const listenersSupported = vueVersion > 2.3
3024

31-
export function functionalSFCsSupported () {
32-
return vueVersion >= 2.5
33-
}
25+
export const functionalSFCsSupported = vueVersion > 2.4
26+
27+
export const scopedSlotsSupported = vueVersion > 2
3428

3529
const shallowAndMount = process.env.TEST_ENV === 'node'
3630
? []

‎test/specs/mount.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describeIf(process.env.TEST_ENV !== 'node',
145145
'prop': 'val'
146146
}
147147
})
148-
if (injectSupported()) {
148+
if (injectSupported) {
149149
// provide is added by Vue, it's a function in Vue > 2.3
150150
if (vueVersion > 2.3) {
151151
expect(typeof wrapper.vm.$options.provide).to.equal('function')

‎test/specs/mounting-options/attrs.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describeWithMountingMethods('options.attrs', (mountingMethod) => {
1010
itSkipIf(
1111
mountingMethod.name === 'renderToString' || isRunningPhantomJS,
1212
'handles inherit attrs', () => {
13-
if (!attrsSupported()) return
13+
if (!attrsSupported) return
1414
const wrapper = mountingMethod(compileToFunctions('<p :id="anAttr" />'), {
1515
attrs: {
1616
anAttr: 'an attribute'

‎test/specs/mounting-options/listeners.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
describeWithShallowAndMount('options.listeners', (mountingMethod) => {
1010
itSkipIf(isRunningPhantomJS,
1111
'handles inherit listeners', () => {
12-
if (!listenersSupported()) return
12+
if (!listenersSupported) return
1313
const aListener = () => {}
1414
const wrapper = mountingMethod(compileToFunctions('<p :id="aListener" />'), {
1515
listeners: {

‎test/specs/mounting-options/provide.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ describeWithMountingMethods('options.provide', (mountingMethod) => {
1919
config.provide = configProvideSave
2020
})
2121

22-
itDoNotRunIf(!injectSupported(),
22+
itDoNotRunIf(!injectSupported,
2323
'provides objects which is injected by mounted component', () => {
24-
if (!injectSupported()) return
24+
if (!injectSupported) return
2525

2626
const wrapper = mountingMethod(ComponentWithInject, {
2727
provide: { fromMount: 'objectValue' }
@@ -32,7 +32,7 @@ describeWithMountingMethods('options.provide', (mountingMethod) => {
3232
expect(HTML).to.contain('objectValue')
3333
})
3434

35-
itDoNotRunIf(!injectSupported(),
35+
itDoNotRunIf(!injectSupported,
3636
'provides function which is injected by mounted component', () => {
3737
const wrapper = mountingMethod(ComponentWithInject, {
3838
provide () {
@@ -47,9 +47,9 @@ describeWithMountingMethods('options.provide', (mountingMethod) => {
4747
expect(HTML).to.contain('functionValue')
4848
})
4949

50-
itDoNotRunIf(!injectSupported() || mountingMethod.name === 'renderToString',
50+
itDoNotRunIf(!injectSupported || mountingMethod.name === 'renderToString',
5151
'supports beforeCreate in component', () => {
52-
if (!injectSupported()) return
52+
if (!injectSupported) return
5353

5454
const wrapper = mountingMethod(ComponentWithInject, {
5555
provide: { fromMount: '_' }
@@ -60,7 +60,7 @@ describeWithMountingMethods('options.provide', (mountingMethod) => {
6060

6161
itSkipIf(mountingMethod.name === 'renderToString',
6262
'injects the provide from the config', () => {
63-
if (!injectSupported()) {
63+
if (!injectSupported) {
6464
return
6565
}
6666
config.provide['fromMount'] = 'globalConfig'
@@ -73,7 +73,7 @@ describeWithMountingMethods('options.provide', (mountingMethod) => {
7373
expect(HTML).to.contain('globalConfig')
7474
})
7575

76-
itDoNotRunIf(!injectSupported(), 'prioritize mounting options over config', () => {
76+
itDoNotRunIf(!injectSupported, 'prioritize mounting options over config', () => {
7777
config.provide['fromMount'] = 'globalConfig'
7878

7979
const wrapper = mountingMethod(ComponentWithInject, {

‎test/specs/wrapper/contains.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describeWithShallowAndMount('contains', (mountingMethod) => {
2424
})
2525

2626
it('returns true if wrapper contains functional Vue component', () => {
27-
if (!functionalSFCsSupported()) {
27+
if (!functionalSFCsSupported) {
2828
return false
2929
}
3030
const TestComponent = {

‎test/specs/wrapper/find.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ describeWithShallowAndMount('find', (mountingMethod) => {
132132
})
133133

134134
it('returns Wrapper of Vue Component matching functional component', () => {
135-
if (!functionalSFCsSupported()) {
135+
if (!functionalSFCsSupported) {
136136
return
137137
}
138138
const TestComponent = {

‎test/specs/wrapper/findAll.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describeWithShallowAndMount('findAll', (mountingMethod) => {
218218
})
219219

220220
it('returns Wrapper of Vue Component matching functional component', () => {
221-
if (!functionalSFCsSupported()) {
221+
if (!functionalSFCsSupported) {
222222
return
223223
}
224224
const TestComponent = {

‎test/specs/wrapper/is.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describeWithShallowAndMount('is', (mountingMethod) => {
6262
})
6363

6464
it('returns true if root node matches functional Component', () => {
65-
if (!functionalSFCsSupported()) {
65+
if (!functionalSFCsSupported) {
6666
return
6767
}
6868
const wrapper = mountingMethod(FunctionalComponent)

‎test/specs/wrapper/props.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describeWithShallowAndMount('props', (mountingMethod) => {
3636
expect(wrapper.props()).to.eql({ prop1: {}, prop2: 'val2' }) // fail
3737
})
3838

39-
itSkipIf(!functionalSFCsSupported(),
39+
itSkipIf(!functionalSFCsSupported,
4040
'works correctly a functional component', () => {
4141
const FunctionalComponent = {
4242
render: h => h('div'),

‎test/specs/wrapper/trigger.spec.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import ComponentWithEvents from '~resources/components/component-with-events.vue'
2-
import { describeWithShallowAndMount } from '~resources/utils'
2+
import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
3+
import {
4+
describeWithShallowAndMount,
5+
itDoNotRunIf,
6+
scopedSlotsSupported
7+
} from '~resources/utils'
8+
import Vue from 'vue'
39

410
describeWithShallowAndMount('trigger', (mountingMethod) => {
511
let info
@@ -116,6 +122,25 @@ describeWithShallowAndMount('trigger', (mountingMethod) => {
116122
wrapper.trigger('keydown')
117123
})
118124

125+
itDoNotRunIf(
126+
!scopedSlotsSupported,
127+
'handles instances without update watchers', () => {
128+
const vm = new Vue()
129+
const item = () => vm.$createElement('button')
130+
const TestComponent = {
131+
render (h) {
132+
return h(ComponentWithScopedSlots, {
133+
scopedSlots: {
134+
noProps: item
135+
}
136+
})
137+
}
138+
}
139+
const wrapper = mountingMethod(TestComponent)
140+
141+
wrapper.findAll('button').trigger('click')
142+
})
143+
119144
it('throws error if options contains a target value', () => {
120145
const wrapper = mountingMethod({ render: (h) => h('div') })
121146
const div = wrapper.find('div')

0 commit comments

Comments
 (0)
Please sign in to comment.