Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: mount.md #12

Open
wants to merge 1 commit into
base: working
Choose a base branch
from
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
48 changes: 24 additions & 24 deletions docs/en/api/mount.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# mount(component {, options}])
# mount(composant {, options}])

- **Arguments:**
- **Arguments :**

- `{Component} component`
- `{Object} options`
- `{Composant} composant`
- `{Objet} options`

- **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 DOM ou le composant Vue correspondant au selecteur.

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

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

```js
import { mount } 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 = mount(Foo)
expect(wrapper.contains('div')).toBe(true)
})
})
```
**With Vue options:**
**Avec options Vue :**

```js
import { mount } 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 = mount(Foo, {
propsData: {
color: 'red'
Expand All @@ -50,23 +50,23 @@ describe('Foo', () => {
})
```

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

```js
import { mount } 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 = mount(Foo, {
attachToDocument: true
})
expect(wrapper.contains('div')).toBe(true)
})
})
```
**Default and named slots:**
**Slot nommé et par défaut :**

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

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

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

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

describe('Foo', () => {
it('renders a div', () => {
it('rend un div', () => {
const $route = { path: 'http://www.example-path.com' }
const wrapper = mount(Foo, {
mocks: {
Expand All @@ -109,7 +109,7 @@ describe('Foo', () => {
})
```

**Stubbing components:**
**Imiter des composants :**

```js
import { mount } from 'vue-test-utils'
Expand All @@ -119,7 +119,7 @@ import Bar from './Bar.vue'
import Faz from './Faz.vue'

describe('Foo', () => {
it('renders a div', () => {
it('rend une div', () => {
const wrapper = mount(Foo, {
stub: {
Bar: '<div class="stubbed />',
Expand All @@ -133,4 +133,4 @@ describe('Foo', () => {
})
```

- **See also:** [Wrapper](wrapper/README.md)
- **Voir aussi :** [Wrapper](wrapper/README.md)