Skip to content

Commit

Permalink
Remove type condition (#1558)
Browse files Browse the repository at this point in the history
In cases where the empty object is already set as default in the config:

See: `stubs`, `mocks` and `methods`
https://github.com/vuejs/vue-test-utils/blob/dev/packages/test-utils/src/config.js

The ? is not necessary. In this case, we can import the config and we will not be forced to check the existence of attributes:

```
import { config } from '@vue/test-utils';

if (config.mocks) {
  config.mocks.i18n = { t: jest.fn() };
  config.mocks.$t = jest.fn();
}
```

and use directly

```
import { config } from '@vue/test-utils';

config.mocks.i18n = { t: jest.fn() };
config.mocks.$t = jest.fn();
```
  • Loading branch information
spetex authored May 25, 2020
1 parent 2858f24 commit a249065
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/test-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ type ShallowMountOptions<V extends Vue> = MountOptions<V>
type ThisTypedShallowMountOptions<V extends Vue> = ShallowMountOptions<V> & ThisType<V>

interface VueTestUtilsConfigOptions {
stubs?: Record<string, Component | boolean | string>
mocks?: Record<string, any>
methods?: Record<string, Function>
stubs: Record<string, Component | boolean | string>
mocks: Record<string, any>
methods: Record<string, Function>
provide?: Record<string, any>,
silent?: Boolean,
showDeprecationWarnings?: boolean
Expand Down

0 comments on commit a249065

Please sign in to comment.