Skip to content

Commit

Permalink
refactor: use spec methods from conditional-specs (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyerburgh authored May 16, 2018
1 parent c8292cc commit 7c5a2dc
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 84 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"babel-preset-flow-vue": "^1.0.0",
"babel-preset-stage-2": "^6.24.1",
"chai": "^4.0.0",
"conditional-specs": "^1.0.1",
"cross-env": "^5.0.0",
"css-loader": "^0.28.4",
"eslint": "^4.18.1",
Expand Down
44 changes: 1 addition & 43 deletions test/resources/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global describe, it*/
/* global describe */

import Vue from 'vue'
import { shallowMount, mount } from '~vue/test-utils'
Expand Down Expand Up @@ -70,45 +70,3 @@ describeWithMountingMethods.only = function (spec, cb) {
describe.only(`${spec} with ${method.name}`, () => cb(method))
})
}

export function itSkipIf (predicate, spec, cb) {
if (predicate) {
it.skip(spec, cb)
} else {
it(spec, cb)
}
}

itSkipIf.only = (predicate, spec, cb) => {
if (predicate) {
it.skip(spec, cb)
} else {
it.only(spec, cb)
}
}

export function itDoNotRunIf (predicate, spec, cb) {
if (predicate) {
() => {}
} else {
it(spec, cb)
}
}

itDoNotRunIf.only = (predicate, spec, cb) => {
if (!predicate) {
it.only(spec, cb)
}
}

export function describeIf (predicate, spec, cb) {
if (predicate) {
describe(spec, cb)
}
}

describeIf.only = (predicate, spec, cb) => {
if (predicate) {
describe(spec, cb)
}
}
6 changes: 4 additions & 2 deletions test/specs/config.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
describeWithShallowAndMount,
itDoNotRunIf,
itSkipIf,
vueVersion
} from '~resources/utils'
import {
itDoNotRunIf,
itSkipIf
} from 'conditional-specs'
import { config, TransitionStub, TransitionGroupStub, createLocalVue } from '~vue/test-utils'
import Vue from 'vue'

Expand Down
6 changes: 2 additions & 4 deletions test/specs/create-local-vue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import { createLocalVue } from '~vue/test-utils'
import Component from '~resources/components/component.vue'
import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
import ComponentWithRouter from '~resources/components/component-with-router.vue'
import {
describeWithShallowAndMount,
itDoNotRunIf
} from '~resources/utils'
import { describeWithShallowAndMount } from '~resources/utils'
import { itDoNotRunIf } from 'conditional-specs'

describeWithShallowAndMount('createLocalVue', (mountingMethod) => {
it('installs Vuex without polluting global Vue', () => {
Expand Down
5 changes: 3 additions & 2 deletions test/specs/mount.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { mount, createLocalVue } from '~vue/test-utils'
import Component from '~resources/components/component.vue'
import ComponentWithProps from '~resources/components/component-with-props.vue'
import ComponentWithMixin from '~resources/components/component-with-mixin.vue'
import { injectSupported, vueVersion, describeIf } from '~resources/utils'
import { injectSupported, vueVersion } from '~resources/utils'
import { describeRunIf } from 'conditional-specs'

describeIf(process.env.TEST_ENV !== 'node',
describeRunIf(process.env.TEST_ENV !== 'node',
'mount', () => {
let consoleError

Expand Down
4 changes: 3 additions & 1 deletion test/specs/mounting-options/attrs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { compileToFunctions } from 'vue-template-compiler'
import { attrsSupported } from '~resources/utils'
import {
describeWithMountingMethods,
itSkipIf,
isRunningPhantomJS
} from '~resources/utils'
import {
itSkipIf
} from 'conditional-specs'

describeWithMountingMethods('options.attrs', (mountingMethod) => {
itSkipIf(
Expand Down
4 changes: 3 additions & 1 deletion test/specs/mounting-options/listeners.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { compileToFunctions } from 'vue-template-compiler'
import { listenersSupported } from '~resources/utils'
import {
describeWithShallowAndMount,
itSkipIf,
isRunningPhantomJS
} from '~resources/utils'
import {
itSkipIf
} from 'conditional-specs'

describeWithShallowAndMount('options.listeners', (mountingMethod) => {
itSkipIf(isRunningPhantomJS,
Expand Down
2 changes: 1 addition & 1 deletion test/specs/mounting-options/localVue.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Vue from 'vue'
import {
describeWithMountingMethods,
itSkipIf,
isRunningPhantomJS,
vueVersion
} from '~resources/utils'
import { createLocalVue } from '~vue/test-utils'
import { itSkipIf } from 'conditional-specs'
import Vuex from 'vuex'

describeWithMountingMethods('options.localVue', (mountingMethod) => {
Expand Down
6 changes: 2 additions & 4 deletions test/specs/mounting-options/mocks.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { createLocalVue, config } from '~vue/test-utils'
import Component from '~resources/components/component.vue'
import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
import {
describeWithMountingMethods,
itDoNotRunIf
} from '~resources/utils'
import { describeWithMountingMethods } from '~resources/utils'
import { itDoNotRunIf } from 'conditional-specs'

describeWithMountingMethods('options.mocks', (mountingMethod) => {
let configMocksSave
Expand Down
4 changes: 2 additions & 2 deletions test/specs/mounting-options/provide.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { config } from '~vue/test-utils'
import ComponentWithInject from '~resources/components/component-with-inject.vue'
import { injectSupported } from '~resources/utils'
import { describeWithMountingMethods } from '~resources/utils'
import {
describeWithMountingMethods,
itDoNotRunIf,
itSkipIf
} from '~resources/utils'
} from 'conditional-specs'

describeWithMountingMethods('options.provide', (mountingMethod) => {
let configProvideSave
Expand Down
2 changes: 1 addition & 1 deletion test/specs/mounting-options/scopedSlots.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
describeWithShallowAndMount,
vueVersion,
itDoNotRunIf,
isRunningPhantomJS
} from '~resources/utils'
import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
import { itDoNotRunIf } from 'conditional-specs'

describeWithShallowAndMount('scopedSlots', (mountingMethod) => {
let _window
Expand Down
6 changes: 4 additions & 2 deletions test/specs/mounting-options/slots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
import {
describeWithMountingMethods,
vueVersion,
itSkipIf,
itDoNotRunIf,
isRunningPhantomJS
} from '~resources/utils'
import {
itSkipIf,
itDoNotRunIf
} from 'conditional-specs'

describeWithMountingMethods('options.slots', (mountingMethod) => {
let _window
Expand Down
6 changes: 2 additions & 4 deletions test/specs/mounting-options/stubs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
import { createLocalVue, config } from '~vue/test-utils'
import { config as serverConfig } from '~vue/server-test-utils'
import Vue from 'vue'
import {
describeWithMountingMethods,
itDoNotRunIf
} from '~resources/utils'
import { describeWithMountingMethods } from '~resources/utils'
import { itDoNotRunIf } from 'conditional-specs'

describeWithMountingMethods('options.stub', (mountingMethod) => {
let info
Expand Down
6 changes: 2 additions & 4 deletions test/specs/renderToString.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { renderToString } from '~vue/server-test-utils'
import Component from '~resources/components/component.vue'
import {
isRunningJSDOM,
itDoNotRunIf
} from '~resources/utils'
import { isRunningJSDOM } from '~resources/utils'
import { itDoNotRunIf } from 'conditional-specs'

describe.skip('renderToString', () => {
itDoNotRunIf(isRunningJSDOM,
Expand Down
5 changes: 3 additions & 2 deletions test/specs/shallow-mount.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import ComponentWithLifecycleHooks from '~resources/components/component-with-li
import ComponentWithoutName from '~resources/components/component-without-name.vue'
import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue'
import RecursiveComponent from '~resources/components/recursive-component.vue'
import { vueVersion, describeIf } from '~resources/utils'
import { vueVersion } from '~resources/utils'
import { describeRunIf } from 'conditional-specs'

describeIf(process.env.TEST_ENV !== 'node',
describeRunIf(process.env.TEST_ENV !== 'node',
'shallowMount', () => {
let info

Expand Down
5 changes: 3 additions & 2 deletions test/specs/shallow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import ComponentWithLifecycleHooks from '~resources/components/component-with-li
import ComponentWithoutName from '~resources/components/component-without-name.vue'
import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue'
import RecursiveComponent from '~resources/components/recursive-component.vue'
import { vueVersion, describeIf } from '~resources/utils'
import { vueVersion } from '~resources/utils'
import { describeRunIf } from 'conditional-specs'

describeIf(process.env.TEST_ENV !== 'node',
describeRunIf(process.env.TEST_ENV !== 'node',
'shallowMount', () => {
let info

Expand Down
4 changes: 2 additions & 2 deletions test/specs/wrapper/contains.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
import {
functionalSFCsSupported,
describeWithShallowAndMount,
isRunningPhantomJS,
itSkipIf
isRunningPhantomJS
} from '~resources/utils'
import { itSkipIf } from 'conditional-specs'
import ComponentWithoutName from '~resources/components/component-without-name.vue'

describeWithShallowAndMount('contains', (mountingMethod) => {
Expand Down
6 changes: 4 additions & 2 deletions test/specs/wrapper/find.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import {
functionalSFCsSupported,
vueVersion,
describeWithShallowAndMount,
isRunningPhantomJS,
isRunningPhantomJS
} from '~resources/utils'
import {
itDoNotRunIf,
itSkipIf
} from '~resources/utils'
} from 'conditional-specs'

describeWithShallowAndMount('find', (mountingMethod) => {
it('returns a Wrapper matching tag selector passed', () => {
Expand Down
6 changes: 4 additions & 2 deletions test/specs/wrapper/findAll.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
import {
functionalSFCsSupported,
describeWithShallowAndMount,
itDoNotRunIf,
itSkipIf,
isRunningPhantomJS
} from '~resources/utils'
import {
itDoNotRunIf,
itSkipIf
} from 'conditional-specs'

describeWithShallowAndMount('findAll', (mountingMethod) => {
it('returns an WrapperArray of elements matching tag selector passed', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/wrapper/isEmpty.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { compileToFunctions } from 'vue-template-compiler'
import {
describeWithShallowAndMount,
itSkipIf,
isRunningPhantomJS
} from '~resources/utils'
import { itSkipIf } from 'conditional-specs'

describeWithShallowAndMount('isEmpty', (mountingMethod) => {
it('returns true if node is empty', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/wrapper/props.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { compileToFunctions } from 'vue-template-compiler'
import ComponentWithProps from '~resources/components/component-with-props.vue'
import {
describeWithShallowAndMount,
itSkipIf,
functionalSFCsSupported
} from '~resources/utils'
import { itSkipIf } from 'conditional-specs'

describeWithShallowAndMount('props', (mountingMethod) => {
it('returns true if wrapper has prop', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/specs/wrapper/trigger.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import ComponentWithEvents from '~resources/components/component-with-events.vue
import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue'
import {
describeWithShallowAndMount,
itDoNotRunIf,
scopedSlotsSupported
} from '~resources/utils'
import Vue from 'vue'
import { itDoNotRunIf } from 'conditional-specs'

describeWithShallowAndMount('trigger', (mountingMethod) => {
let info
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1753,6 +1753,10 @@ [email protected], concat-stream@^1.4.10, concat-stream@^1.5.0, concat-stream@
readable-stream "^2.2.2"
typedarray "^0.0.6"

conditional-specs@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/conditional-specs/-/conditional-specs-1.0.1.tgz#1137ca6f83e5de848853cf0cfac78fe858b40a9a"

config-chain@~1.1.10, config-chain@~1.1.11:
version "1.1.11"
resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2"
Expand Down

0 comments on commit 7c5a2dc

Please sign in to comment.