-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathvue-router.js
34 lines (27 loc) · 1.18 KB
/
vue-router.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Please notice that this example is a draft example on how to test
// the router.
// Related issue on Vue Test Utils: https://github.com/vuejs/vue-test-utils-next/issues/152
import '@testing-library/jest-dom'
import {waitFor} from '@testing-library/dom'
import {render, fireEvent} from '..'
import App from './components/Router/App.vue'
import Home from './components/Router/Home.vue'
import About from './components/Router/About.vue'
const routes = [
{path: '/', component: Home},
{path: '/about', component: About},
]
test('full app rendering/navigating', async () => {
// Notice how we pass a `routes` object to our render function.
const {findByText, getByText, getByTestId} = render(App, {routes})
// Vue Router navigation is async, so we need to wait until the
// initial render happens
expect(await findByText('You are home')).toBeInTheDocument()
await fireEvent.click(getByTestId('about-link'))
// Same thing here: Vue Router navigation is async, so we need to wait until the
// navigation happens
await waitFor(() =>
expect(getByTestId('location-display')).toHaveTextContent('/about'),
)
expect(getByText('You are on the about page')).toBeInTheDocument()
})