Skip to content

Commit

Permalink
fix: add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ygj6 committed Nov 22, 2021
1 parent ce113a1 commit 9dfbe66
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/playground/preload/__tests__/preload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,15 @@ if (isBuild) {
const appHtml = await page.content()
expect(appHtml).toMatch('This is <b>home</b> page.')
})

test('dynamic import with comments', async () => {
await page.goto(viteTestUrl + '/#/hello')
const html = await page.content()
expect(html).toMatch(
/link rel="modulepreload".*?href="\/assets\/Hello\.\w{8}\.js"/
)
expect(html).toMatch(
/link rel="stylesheet".*?href="\/assets\/Hello\.\w{8}\.css"/
)
})
}
7 changes: 6 additions & 1 deletion packages/playground/preload/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import Home from './src/components/Home.vue'

const routes = [
{ path: '/', name: 'Home', component: Home },
{
path: '/hello',
name: 'Hello',
component: () => import(/* a comment */ './src/components/Hello.vue')
},
{
path: '/about',
name: 'About',
component: () => import(/*breaks*/ './src/components/About.vue')
component: () => import('./src/components/About.vue')
} // Lazy load route component
]

Expand Down
18 changes: 18 additions & 0 deletions packages/playground/preload/src/components/Hello.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<h1>{{ msg }}</h1>
<div>
This is <b>hello</b> page.
<br />
Go to <router-link to="/">Home</router-link> page
</div>
</template>

<script setup>
const msg = 'hello'
</script>

<style scoped>
h1 {
color: red;
}
</style>
2 changes: 2 additions & 0 deletions packages/playground/preload/src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This is <b>home</b> page.
<br />
Go to <router-link to="/about">About</router-link> page
<br />
Go to <router-link to="/hello">Hello</router-link> page
</div>
</template>

Expand Down

0 comments on commit 9dfbe66

Please sign in to comment.