Skip to content

Commit 7c5a2dc

Browse files
authored
refactor: use spec methods from conditional-specs (#616)
1 parent c8292cc commit 7c5a2dc

23 files changed

+54
-84
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"babel-preset-flow-vue": "^1.0.0",
4040
"babel-preset-stage-2": "^6.24.1",
4141
"chai": "^4.0.0",
42+
"conditional-specs": "^1.0.1",
4243
"cross-env": "^5.0.0",
4344
"css-loader": "^0.28.4",
4445
"eslint": "^4.18.1",

Diff for: test/resources/utils.js

+1-43
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global describe, it*/
1+
/* global describe */
22

33
import Vue from 'vue'
44
import { shallowMount, mount } from '~vue/test-utils'
@@ -70,45 +70,3 @@ describeWithMountingMethods.only = function (spec, cb) {
7070
describe.only(`${spec} with ${method.name}`, () => cb(method))
7171
})
7272
}
73-
74-
export function itSkipIf (predicate, spec, cb) {
75-
if (predicate) {
76-
it.skip(spec, cb)
77-
} else {
78-
it(spec, cb)
79-
}
80-
}
81-
82-
itSkipIf.only = (predicate, spec, cb) => {
83-
if (predicate) {
84-
it.skip(spec, cb)
85-
} else {
86-
it.only(spec, cb)
87-
}
88-
}
89-
90-
export function itDoNotRunIf (predicate, spec, cb) {
91-
if (predicate) {
92-
() => {}
93-
} else {
94-
it(spec, cb)
95-
}
96-
}
97-
98-
itDoNotRunIf.only = (predicate, spec, cb) => {
99-
if (!predicate) {
100-
it.only(spec, cb)
101-
}
102-
}
103-
104-
export function describeIf (predicate, spec, cb) {
105-
if (predicate) {
106-
describe(spec, cb)
107-
}
108-
}
109-
110-
describeIf.only = (predicate, spec, cb) => {
111-
if (predicate) {
112-
describe(spec, cb)
113-
}
114-
}

Diff for: test/specs/config.spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {
22
describeWithShallowAndMount,
3-
itDoNotRunIf,
4-
itSkipIf,
53
vueVersion
64
} from '~resources/utils'
5+
import {
6+
itDoNotRunIf,
7+
itSkipIf
8+
} from 'conditional-specs'
79
import { config, TransitionStub, TransitionGroupStub, createLocalVue } from '~vue/test-utils'
810
import Vue from 'vue'
911

Diff for: test/specs/create-local-vue.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import { createLocalVue } from '~vue/test-utils'
66
import Component from '~resources/components/component.vue'
77
import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
88
import ComponentWithRouter from '~resources/components/component-with-router.vue'
9-
import {
10-
describeWithShallowAndMount,
11-
itDoNotRunIf
12-
} from '~resources/utils'
9+
import { describeWithShallowAndMount } from '~resources/utils'
10+
import { itDoNotRunIf } from 'conditional-specs'
1311

1412
describeWithShallowAndMount('createLocalVue', (mountingMethod) => {
1513
it('installs Vuex without polluting global Vue', () => {

Diff for: test/specs/mount.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { mount, createLocalVue } from '~vue/test-utils'
44
import Component from '~resources/components/component.vue'
55
import ComponentWithProps from '~resources/components/component-with-props.vue'
66
import ComponentWithMixin from '~resources/components/component-with-mixin.vue'
7-
import { injectSupported, vueVersion, describeIf } from '~resources/utils'
7+
import { injectSupported, vueVersion } from '~resources/utils'
8+
import { describeRunIf } from 'conditional-specs'
89

9-
describeIf(process.env.TEST_ENV !== 'node',
10+
describeRunIf(process.env.TEST_ENV !== 'node',
1011
'mount', () => {
1112
let consoleError
1213

Diff for: test/specs/mounting-options/attrs.spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { compileToFunctions } from 'vue-template-compiler'
22
import { attrsSupported } from '~resources/utils'
33
import {
44
describeWithMountingMethods,
5-
itSkipIf,
65
isRunningPhantomJS
76
} from '~resources/utils'
7+
import {
8+
itSkipIf
9+
} from 'conditional-specs'
810

911
describeWithMountingMethods('options.attrs', (mountingMethod) => {
1012
itSkipIf(

Diff for: test/specs/mounting-options/listeners.spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { compileToFunctions } from 'vue-template-compiler'
22
import { listenersSupported } from '~resources/utils'
33
import {
44
describeWithShallowAndMount,
5-
itSkipIf,
65
isRunningPhantomJS
76
} from '~resources/utils'
7+
import {
8+
itSkipIf
9+
} from 'conditional-specs'
810

911
describeWithShallowAndMount('options.listeners', (mountingMethod) => {
1012
itSkipIf(isRunningPhantomJS,

Diff for: test/specs/mounting-options/localVue.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Vue from 'vue'
22
import {
33
describeWithMountingMethods,
4-
itSkipIf,
54
isRunningPhantomJS,
65
vueVersion
76
} from '~resources/utils'
87
import { createLocalVue } from '~vue/test-utils'
8+
import { itSkipIf } from 'conditional-specs'
99
import Vuex from 'vuex'
1010

1111
describeWithMountingMethods('options.localVue', (mountingMethod) => {

Diff for: test/specs/mounting-options/mocks.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { createLocalVue, config } from '~vue/test-utils'
22
import Component from '~resources/components/component.vue'
33
import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
4-
import {
5-
describeWithMountingMethods,
6-
itDoNotRunIf
7-
} from '~resources/utils'
4+
import { describeWithMountingMethods } from '~resources/utils'
5+
import { itDoNotRunIf } from 'conditional-specs'
86

97
describeWithMountingMethods('options.mocks', (mountingMethod) => {
108
let configMocksSave

Diff for: test/specs/mounting-options/provide.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { config } from '~vue/test-utils'
22
import ComponentWithInject from '~resources/components/component-with-inject.vue'
33
import { injectSupported } from '~resources/utils'
4+
import { describeWithMountingMethods } from '~resources/utils'
45
import {
5-
describeWithMountingMethods,
66
itDoNotRunIf,
77
itSkipIf
8-
} from '~resources/utils'
8+
} from 'conditional-specs'
99

1010
describeWithMountingMethods('options.provide', (mountingMethod) => {
1111
let configProvideSave

Diff for: test/specs/mounting-options/scopedSlots.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {
22
describeWithShallowAndMount,
33
vueVersion,
4-
itDoNotRunIf,
54
isRunningPhantomJS
65
} from '~resources/utils'
76
import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
7+
import { itDoNotRunIf } from 'conditional-specs'
88

99
describeWithShallowAndMount('scopedSlots', (mountingMethod) => {
1010
let _window

Diff for: test/specs/mounting-options/slots.spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
55
import {
66
describeWithMountingMethods,
77
vueVersion,
8-
itSkipIf,
9-
itDoNotRunIf,
108
isRunningPhantomJS
119
} from '~resources/utils'
10+
import {
11+
itSkipIf,
12+
itDoNotRunIf
13+
} from 'conditional-specs'
1214

1315
describeWithMountingMethods('options.slots', (mountingMethod) => {
1416
let _window

Diff for: test/specs/mounting-options/stubs.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
55
import { createLocalVue, config } from '~vue/test-utils'
66
import { config as serverConfig } from '~vue/server-test-utils'
77
import Vue from 'vue'
8-
import {
9-
describeWithMountingMethods,
10-
itDoNotRunIf
11-
} from '~resources/utils'
8+
import { describeWithMountingMethods } from '~resources/utils'
9+
import { itDoNotRunIf } from 'conditional-specs'
1210

1311
describeWithMountingMethods('options.stub', (mountingMethod) => {
1412
let info

Diff for: test/specs/renderToString.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { renderToString } from '~vue/server-test-utils'
22
import Component from '~resources/components/component.vue'
3-
import {
4-
isRunningJSDOM,
5-
itDoNotRunIf
6-
} from '~resources/utils'
3+
import { isRunningJSDOM } from '~resources/utils'
4+
import { itDoNotRunIf } from 'conditional-specs'
75

86
describe.skip('renderToString', () => {
97
itDoNotRunIf(isRunningJSDOM,

Diff for: test/specs/shallow-mount.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import ComponentWithLifecycleHooks from '~resources/components/component-with-li
88
import ComponentWithoutName from '~resources/components/component-without-name.vue'
99
import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue'
1010
import RecursiveComponent from '~resources/components/recursive-component.vue'
11-
import { vueVersion, describeIf } from '~resources/utils'
11+
import { vueVersion } from '~resources/utils'
12+
import { describeRunIf } from 'conditional-specs'
1213

13-
describeIf(process.env.TEST_ENV !== 'node',
14+
describeRunIf(process.env.TEST_ENV !== 'node',
1415
'shallowMount', () => {
1516
let info
1617

Diff for: test/specs/shallow.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import ComponentWithLifecycleHooks from '~resources/components/component-with-li
88
import ComponentWithoutName from '~resources/components/component-without-name.vue'
99
import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue'
1010
import RecursiveComponent from '~resources/components/recursive-component.vue'
11-
import { vueVersion, describeIf } from '~resources/utils'
11+
import { vueVersion } from '~resources/utils'
12+
import { describeRunIf } from 'conditional-specs'
1213

13-
describeIf(process.env.TEST_ENV !== 'node',
14+
describeRunIf(process.env.TEST_ENV !== 'node',
1415
'shallowMount', () => {
1516
let info
1617

Diff for: test/specs/wrapper/contains.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
66
import {
77
functionalSFCsSupported,
88
describeWithShallowAndMount,
9-
isRunningPhantomJS,
10-
itSkipIf
9+
isRunningPhantomJS
1110
} from '~resources/utils'
11+
import { itSkipIf } from 'conditional-specs'
1212
import ComponentWithoutName from '~resources/components/component-without-name.vue'
1313

1414
describeWithShallowAndMount('contains', (mountingMethod) => {

Diff for: test/specs/wrapper/find.spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import {
1111
functionalSFCsSupported,
1212
vueVersion,
1313
describeWithShallowAndMount,
14-
isRunningPhantomJS,
14+
isRunningPhantomJS
15+
} from '~resources/utils'
16+
import {
1517
itDoNotRunIf,
1618
itSkipIf
17-
} from '~resources/utils'
19+
} from 'conditional-specs'
1820

1921
describeWithShallowAndMount('find', (mountingMethod) => {
2022
it('returns a Wrapper matching tag selector passed', () => {

Diff for: test/specs/wrapper/findAll.spec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
99
import {
1010
functionalSFCsSupported,
1111
describeWithShallowAndMount,
12-
itDoNotRunIf,
13-
itSkipIf,
1412
isRunningPhantomJS
1513
} from '~resources/utils'
14+
import {
15+
itDoNotRunIf,
16+
itSkipIf
17+
} from 'conditional-specs'
1618

1719
describeWithShallowAndMount('findAll', (mountingMethod) => {
1820
it('returns an WrapperArray of elements matching tag selector passed', () => {

Diff for: test/specs/wrapper/isEmpty.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { compileToFunctions } from 'vue-template-compiler'
22
import {
33
describeWithShallowAndMount,
4-
itSkipIf,
54
isRunningPhantomJS
65
} from '~resources/utils'
6+
import { itSkipIf } from 'conditional-specs'
77

88
describeWithShallowAndMount('isEmpty', (mountingMethod) => {
99
it('returns true if node is empty', () => {

Diff for: test/specs/wrapper/props.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { compileToFunctions } from 'vue-template-compiler'
22
import ComponentWithProps from '~resources/components/component-with-props.vue'
33
import {
44
describeWithShallowAndMount,
5-
itSkipIf,
65
functionalSFCsSupported
76
} from '~resources/utils'
7+
import { itSkipIf } from 'conditional-specs'
88

99
describeWithShallowAndMount('props', (mountingMethod) => {
1010
it('returns true if wrapper has prop', () => {

Diff for: test/specs/wrapper/trigger.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import ComponentWithEvents from '~resources/components/component-with-events.vue
22
import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
33
import {
44
describeWithShallowAndMount,
5-
itDoNotRunIf,
65
scopedSlotsSupported
76
} from '~resources/utils'
87
import Vue from 'vue'
8+
import { itDoNotRunIf } from 'conditional-specs'
99

1010
describeWithShallowAndMount('trigger', (mountingMethod) => {
1111
let info

Diff for: yarn.lock

+4
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,10 @@ [email protected], concat-stream@^1.4.10, concat-stream@^1.5.0, concat-stream@
17531753
readable-stream "^2.2.2"
17541754
typedarray "^0.0.6"
17551755

1756+
conditional-specs@^1.0.1:
1757+
version "1.0.1"
1758+
resolved "https://registry.yarnpkg.com/conditional-specs/-/conditional-specs-1.0.1.tgz#1137ca6f83e5de848853cf0cfac78fe858b40a9a"
1759+
17561760
config-chain@~1.1.10, config-chain@~1.1.11:
17571761
version "1.1.11"
17581762
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2"

0 commit comments

Comments
 (0)