-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10835 from qmonmert/vueroutertest
Vue: add tests for HomeRouter
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/resources/generator/client/vue/webapp/app/router.ts.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...urces/generator/client/vue/webapp/app/test/webapp/unit/router/HomeRouter.spec.ts.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { mount, VueWrapper } from '@vue/test-utils'; | ||
import { beforeEach, describe, expect, it } from 'vitest'; | ||
import { createRouter, createWebHistory, Router } from 'vue-router'; | ||
import { routes } from '@/router'; | ||
import HomepageVue from '@/home/infrastructure/primary/HomepageVue.vue'; | ||
|
||
let router: Router; | ||
beforeEach(async () => { | ||
router = createRouter({ | ||
history: createWebHistory(), | ||
routes, | ||
}); | ||
}); | ||
|
||
const wrap = (): VueWrapper => { | ||
return mount(HomepageVue, { | ||
global: { | ||
plugins: [router], | ||
}, | ||
}); | ||
}; | ||
|
||
describe('Router', () => { | ||
describe('Navigation on HomepageVue', () => { | ||
it('should navigate on HomepageVue when the URL is /', async () => { | ||
router.push('/'); | ||
await router.isReady(); | ||
const wrapper = wrap(); | ||
expect(wrapper.html()).toContain('Vue 3 + TypeScript + Vite'); | ||
}); | ||
|
||
it('should navigate on HomepageVue when the URL is /home', async () => { | ||
router.push('/home'); | ||
await router.isReady(); | ||
const wrapper = wrap(); | ||
expect(wrapper.html()).toContain('Vue 3 + TypeScript + Vite'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters