Skip to content

Commit 4be14aa

Browse files
committed
Cleanup examples
1 parent b203b0d commit 4be14aa

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

docs/api/index.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,21 @@ document.body.innerHTML = `
6868
</div>
6969
`
7070
71+
const Component = {
72+
template: `<p>Vue Component</p>`
73+
}
74+
7175
test('mounts on a specific element', () => {
7276
const wrapper = mount(Component, {
7377
attachTo: document.getElementById('app')
7478
})
7579
76-
console.log(document.body.innerHTML)
77-
/*
78-
* <div>
79-
* <h1>Non Vue app</h1>
80-
* <div>Vue Component</div>
81-
* </div>
82-
*/
80+
expect(document.body.innerHTML).toBe(`
81+
<div>
82+
<h1>Non Vue app</h1>
83+
<div id="app"><div data-v-app=""><p>Vue Component</p></div></div>
84+
</div>
85+
`)
8386
})
8487
```
8588

@@ -96,7 +99,7 @@ attrs?: Record<string, unknown>
9699
**Details:**
97100

98101
```js
99-
test('assigns attributes', () => {
102+
test('attrs', () => {
100103
const wrapper = mount(Component, {
101104
attrs: {
102105
id: 'hello',
@@ -111,7 +114,7 @@ test('assigns attributes', () => {
111114
})
112115
```
113116

114-
Notice that setting a prop will always trump an attribute:
117+
Notice that setting a defined prop will always trump an attribute:
115118

116119
```js
117120
test('attribute is overridden by a prop with the same name', () => {
@@ -145,14 +148,14 @@ data?: () => {} extends Data ? any : Data extends object ? Partial<Data> : any
145148

146149
```vue
147150
<template>
148-
<div>Foo is {{ foo }}</div>
151+
<div>Hello {{ message }}</div>
149152
</template>
150153
151154
<script>
152155
export default {
153156
data() {
154157
return {
155-
foo: 'foo'
158+
message: 'everyone'
156159
}
157160
}
158161
}
@@ -162,16 +165,16 @@ export default {
162165
`Component.spec.js`:
163166

164167
```js
165-
test('overrides data', () => {
168+
test('data', () => {
166169
const wrapper = mount(Component, {
167170
data() {
168171
return {
169-
foo: 'bar'
172+
message: 'world'
170173
}
171174
}
172175
})
173176
174-
expect(wrapper.html()).toContain('Foo is bar')
177+
expect(wrapper.html()).toContain('Hello world')
175178
})
176179
```
177180

@@ -234,15 +237,15 @@ slots?: { [key: string]: Slot } & { default?: Slot }
234237

235238
**Details:**
236239

237-
Slots can be a component imported from a `.vue` file or a render function. Currently providing an object with a `template` key is not supported.
240+
Slots can be a string, a component imported from a `.vue` file or a render function. Currently providing an object with a `template` key is not supported.
238241

239242
`Component.vue`:
240243

241244
```vue
242245
<template>
243-
<slot name="foo" />
246+
<slot name="first" />
244247
<slot />
245-
<slot name="bar" />
248+
<slot name="second" />
246249
</template>
247250
```
248251

@@ -255,13 +258,12 @@ test('renders slots content', () => {
255258
const wrapper = mount(Component, {
256259
slots: {
257260
default: 'Default',
258-
foo: h('h1', {}, 'Named Slot'),
259-
bar: Bar
261+
first: h('h1', {}, 'Named Slot'),
262+
second: Bar
260263
}
261264
})
262265

263-
console.log(wrapper.html())
264-
// logs '<h1>Named Slot</h1>Default<div>Bar</div>'
266+
expect(wrapper.html()).toBe('<h1>Named Slot</h1>Default<div>Bar</div>')
265267
})
266268
```
267269

0 commit comments

Comments
 (0)