Skip to content

Commit 5d78c98

Browse files
committed
update e2e
1 parent 08a09bc commit 5d78c98

File tree

10 files changed

+138
-47
lines changed

10 files changed

+138
-47
lines changed

e2e/example.test.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
describe('example', () => {
2-
beforeAll(async () => {
3-
await page.goto('http://localhost:8080/')
4-
})
1+
;['composable', 'legacy'].forEach(pattern => {
2+
describe(`${pattern}`, () => {
3+
beforeAll(async () => {
4+
await page.goto(`http://localhost:8080/${pattern}/`)
5+
})
6+
7+
test('initial rendering', async () => {
8+
await expect(page).toMatch('言語')
9+
await expect(page).toMatch('こんにちは、世界!')
10+
})
511

6-
test('rendering', async () => {
7-
await expect(page).toMatch('こんにちは、世界!')
12+
test('change locale', async () => {
13+
await page.select('#app select', 'en')
14+
await expect(page).toMatch('Language')
15+
await expect(page).toMatch('hello, world!')
16+
})
817
})
918
})

example/App.vue

Lines changed: 0 additions & 20 deletions
This file was deleted.

example/composable/App.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<template>
2+
<form>
3+
<label>{{ t('language') }}</label>
4+
<select v-model="locale">
5+
<option value="en">en</option>
6+
<option value="ja">ja</option>
7+
</select>
8+
</form>
9+
<p>{{ t('hello') }}</p>
10+
</template>
11+
12+
<script>
13+
import { useI18n } from 'vue-i18n'
14+
15+
export default {
16+
name: 'App',
17+
setup() {
18+
return useI18n({
19+
locale: 'ja'
20+
})
21+
}
22+
}
23+
</script>
24+
25+
<i18n>
26+
{
27+
"en": {
28+
"language": "Language",
29+
"hello": "hello, world!"
30+
},
31+
"ja": {
32+
"language": "言語",
33+
"hello": "こんにちは、世界!"
34+
}
35+
}
36+
</i18n>

example/composable/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>vue-i18n-loader example</title>
6+
</head>
7+
<body>
8+
<div id="app">
9+
<App />
10+
</div>
11+
<script src="/dist/composable.js"></script>
12+
</body>
13+
</html>

example/composable/main.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { createApp } from 'vue'
2+
import { createI18nComposer } from 'vue-i18n'
3+
import App from './App.vue'
4+
5+
const i18n = createI18nComposer({
6+
locale: 'ja',
7+
messages: {}
8+
})
9+
10+
const app = createApp(App)
11+
12+
app.use(i18n)
13+
app.mount('#app')

example/legacy/App.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<form>
3+
<label>{{ $t('language') }}</label>
4+
<select v-model="$i18n.locale">
5+
<option value="en">en</option>
6+
<option value="ja">ja</option>
7+
</select>
8+
</form>
9+
<p>{{ $t('hello') }}</p>
10+
</template>
11+
12+
<script>
13+
export default {
14+
name: 'App'
15+
}
16+
</script>
17+
18+
<i18n>
19+
{
20+
"en": {
21+
"language": "Language",
22+
"hello": "hello, world!"
23+
},
24+
"ja": {
25+
"language": "言語",
26+
"hello": "こんにちは、世界!"
27+
}
28+
}
29+
</i18n>

example/index.html renamed to example/legacy/index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
<title>vue-i18n-loader example</title>
66
</head>
77
<body>
8-
<div id="app"></div>
9-
<script src="/dist/bundle.js"></script>
8+
<div id="app">
9+
<App />
10+
</div>
11+
<script src="/dist/legacy.js"></script>
1012
</body>
1113
</html>

example/legacy/main.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { createApp } from 'vue'
2+
import { createI18n } from 'vue-i18n'
3+
import App from './App.vue'
4+
5+
const i18n = createI18n({
6+
locale: 'ja',
7+
messages: {}
8+
})
9+
10+
const app = createApp(App)
11+
12+
app.use(i18n)
13+
app.mount('#app')

example/main.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

example/webpack.config.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
const path = require('path')
2-
const VueLoaderPlugin = require('vue-loader/lib/plugin')
2+
const { VueLoaderPlugin } = require('vue-loader')
33

44
module.exports = {
55
mode: 'development',
6-
entry: path.resolve(__dirname, './main.js'),
6+
entry: {
7+
composable: path.resolve(__dirname, './composable/main.js'),
8+
legacy: path.resolve(__dirname, './legacy/main.js')
9+
},
710
output: {
811
path: path.resolve(__dirname, 'dist'),
9-
filename: 'bundle.js',
12+
filename: '[name].js',
1013
publicPath: '/dist/'
1114
},
15+
resolve: {
16+
alias: {
17+
// this isn't technically needed, since the default `vue` entry for bundlers
18+
// is a simple `export * from '@vue/runtime-dom`. However having this
19+
// extra re-export somehow causes webpack to always invalidate the module
20+
// on the first HMR update and causes the page to reload.
21+
'vue': '@vue/runtime-dom'
22+
}
23+
},
1224
devServer: {
1325
stats: 'minimal',
1426
contentBase: __dirname

0 commit comments

Comments
 (0)