Skip to content

Commit 29e895d

Browse files
committed
Cleanup examples
1 parent ba46ade commit 29e895d

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

docs/vue-testing-library/examples.md

+11-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ title: Examples
66
## Basic example
77

88
```html
9-
<!-- src/TestComponent.vue -->
109
<template>
1110
<div>
1211
<p>Times clicked: {{ count }}</p>
@@ -16,11 +15,9 @@ title: Examples
1615

1716
<script>
1817
export default {
19-
data() {
20-
return {
21-
count: 0,
22-
}
23-
},
18+
data: () => ({
19+
count: 0,
20+
}),
2421
2522
methods: {
2623
increment() {
@@ -32,16 +29,15 @@ title: Examples
3229
```
3330

3431
```js
35-
// src/TestComponent.spec.js
3632
import { render, fireEvent, cleanup } from '@testing-library/vue'
37-
import TestComponent from './TestComponent.vue'
33+
import Component from './Component.vue'
3834

3935
// automatically unmount and cleanup DOM after the test is finished.
4036
afterEach(cleanup)
4137

42-
it('increments value on click', async () => {
38+
test('increments value on click', async () => {
4339
// The render method returns a collection of utilities to query your component.
44-
const { getByText } = render(TestComponent)
40+
const { getByText } = render(Component)
4541

4642
// getByText returns the first matching node for the provided text, and
4743
// throws an error if no elements match or if more than one match is found.
@@ -71,18 +67,16 @@ it('increments value on click', async () => {
7167

7268
<script>
7369
export default {
74-
data() {
75-
return {
76-
user: 'Alice',
77-
}
78-
},
70+
data: () => ({
71+
user: 'Alice',
72+
}),
7973
}
8074
</script>
8175
```
8276

8377
```js
8478
import { render, fireEvent, cleanup } from '@testing-library/vue'
85-
import Component from './Component'
79+
import Component from './Component.vue'
8680

8781
afterEach(cleanup)
8882

@@ -92,6 +86,7 @@ test('properly handles v-model', async () => {
9286
// Asserts initial state.
9387
getByText('Hi, my name is Alice')
9488

89+
// Get the input DOM node by querying the associated label.
9590
const usernameInput = getByLabelText(/username/i)
9691

9792
// Updates the <input> value and triggers an `input` event.

0 commit comments

Comments
 (0)