Skip to content

Commit

Permalink
refactor: silentWarnings to silent (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
38elements authored and eddyerburgh committed Jun 17, 2018
1 parent 8011846 commit 7302e05
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/api/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import VueTestUtils from '@vue/test-utils'
VueTestUtils.config.logModifiedComponents = false
```

### `silentWarnings`
### `silent`

- type: `Boolean`
- default: `true`
Expand All @@ -106,5 +106,5 @@ Example:
```js
import VueTestUtils from '@vue/test-utils'

VueTestUtils.config.silentWarnings = false
VueTestUtils.config.silent = false
```
1 change: 1 addition & 0 deletions packages/server-test-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface VueTestUtilsConfigOptions {
methods?: Record<string, Function>
provide?: object,
logModifiedComponents?: Boolean
silent?: Boolean
}

export declare let config: VueTestUtilsConfigOptions
Expand Down
2 changes: 2 additions & 0 deletions packages/server-test-utils/types/test/renderToString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ config.methods = {
config.provide = {
foo: {}
}
config.logModifiedComponents = true
config.silent = true
2 changes: 1 addition & 1 deletion packages/test-utils/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export default {
methods: {},
provide: {},
logModifiedComponents: true,
silentWarnings: true
silent: true
}
2 changes: 1 addition & 1 deletion packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ export default class Wrapper implements BaseWrapper {
*/
setProps (data: Object) {
const originalConfig = Vue.config.silent
Vue.config.silent = config.silentWarnings
Vue.config.silent = config.silent
if (this.isFunctionalComponent) {
throwError(
`wrapper.setProps() cannot be called on a ` +
Expand Down
1 change: 1 addition & 0 deletions packages/test-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ interface VueTestUtilsConfigOptions {
methods?: Record<string, Function>
provide?: object,
logModifiedComponents?: Boolean
silent?: Boolean
}

export declare function createLocalVue (): typeof Vue
Expand Down
2 changes: 2 additions & 0 deletions packages/test-utils/types/test/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@ config.methods = {
config.provide = {
foo: {}
}
config.logModifiedComponents = true
config.silent = true
14 changes: 7 additions & 7 deletions test/specs/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
import Vue from 'vue'

describeWithShallowAndMount('config', mountingMethod => {
let configStubsSave, consoleError, configLogSave, configSilentWarningsSave
let configStubsSave, consoleError, configLogSave, configSilentSave

beforeEach(() => {
TransitionGroupStub.name = 'another-temp-name'
TransitionStub.name = 'a-temp-name'
configStubsSave = config.stubs
configLogSave = config.logModifiedComponents
configSilentWarningsSave = config.silentWarnings
configSilentSave = config.silent
consoleError = sinon.stub(console, 'error')
})

Expand All @@ -26,7 +26,7 @@ describeWithShallowAndMount('config', mountingMethod => {
TransitionStub.name = 'transition'
config.stubs = configStubsSave
config.logModifiedComponents = configLogSave
config.silentWarnings = configSilentWarningsSave
config.silent = configSilentSave
consoleError.restore()
})

Expand Down Expand Up @@ -141,8 +141,8 @@ describeWithShallowAndMount('config', mountingMethod => {
expect(wrapper.contains(TransitionStub)).to.equal(false)
})

it("doesn't throw Vue warning when silentWarnings is set to true", () => {
config.silentWarnings = true
it("doesn't throw Vue warning when silent is set to true", () => {
config.silent = true
const localVue = createLocalVue()
const wrapper = mountingMethod(ComponentWithProps, {
propsData: {
Expand All @@ -157,8 +157,8 @@ describeWithShallowAndMount('config', mountingMethod => {
expect(consoleError.called).to.equal(false)
})

it('does throw Vue warning when silentWarnings is set to false', () => {
config.silentWarnings = false
it('does throw Vue warning when silent is set to false', () => {
config.silent = false
const localVue = createLocalVue()
const wrapper = mountingMethod(ComponentWithProps, {
propsData: {
Expand Down

0 comments on commit 7302e05

Please sign in to comment.