Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions docs/en/api/shallow.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
# shallow(component {, options}])
# shallow(composant {, options}])

- **Arguments:**
- **Paramètres :**

- `{Component} component`
- `{Component} component : un composant Vue`
- `{Object} options`
- `{boolean} attachToDocument`
- `{boolean} attachToDocument : attacher au document`
- `{Object} context`
- `{Object} slots`
- `{Array<Componet|Object>|Component|String} default`
- `{Array<Componet|Object>|Component|String} named`
- `{Object} mocks`
- `{Array<Componet|Object>|Component|String} default : défaut`
- `{Array<Componet|Object>|Component|String} named : nommés`
- `{Object} mocks : imitations`
- `{Object|Array<string>} stubs`
- `{boolean} clone`
- `{Object} children`
- `{Vue} localVue`
- `{Object} children : enfant`
- `{Vue} localVue : instance locale de Vue`

- **Returns:** `{Wrapper}`
- **Retourne :** `{Wrapper}`

- **Options:**
- **Options :**

See [options](./options.md)
Voir [options](./options.md)

- **Usage:**
- **Utilisation :**

Returns [`Wrapper`](./wrapper/README.md) of first DOM node or Vue component matching selector.
Retourne un [`Wrapper`](./wrapper/README.md) du premier nœud du DOM ou le composant Vue correspondant au sélecteur.

Stubs all child components.
Substitue tous les composants enfants.

Use any valid [selector](./selectors.md).
Utilise n'importe quel [sélecteur valide](./selectors.md)

**Without options:**
**Sans options :**

```js
import { shallow } from 'vue-test-utils'
import { expect } from 'chai'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('rend une div', () => {
const wrapper = shallow(Foo)
expect(wrapper.contains('div')).toBe(true)
})
})
```

**With Vue options:**
**Avec des options Vue :**

```js
import { shallow } from 'vue-test-utils'
import { expect } from 'chai'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('rend une div', () => {
const wrapper = shallow(Foo, {
propsData: {
color: 'red'
Expand All @@ -63,15 +63,15 @@ describe('Foo', () => {
})
```

**Attach to DOM:**
**Attacher au DOM :**

```js
import { shallow } from 'vue-test-utils'
import { expect } from 'chai'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('rend une div', () => {
const wrapper = shallow(Foo, {
attachToDocument: true
})
Expand All @@ -80,7 +80,7 @@ describe('Foo', () => {
})
```

**Default and named slots:**
**Slots par défaut et nommés :**

```js
import { shallow } from 'vue-test-utils'
Expand All @@ -90,11 +90,11 @@ import Bar from './Bar.vue'
import FooBar from './FooBar.vue'

describe('Foo', () => {
it('renders a div', () => {
it('rend une div', () => {
const wrapper = shallow(Foo, {
slots: {
default: [Bar, FooBar],
fooBar: FooBar, // Will match <slot name="FooBar" />,
fooBar: FooBar, // Va correspondre à <slot name="FooBar" />,
foo: '<div />'
}
})
Expand All @@ -103,15 +103,15 @@ describe('Foo', () => {
})
```

**Stubbing global properties:**
**Substituer des propriétés globales :**

```js
import { shallow } from 'vue-test-utils'
import { expect } from 'chai'
import Foo from './Foo.vue'

describe('Foo', () => {
it('renders a div', () => {
it('rend une div', () => {
const $route = { path: 'http://www.example-path.com' }
const wrapper = shallow(Foo, {
mocks: {
Expand Down