-
-
Notifications
You must be signed in to change notification settings - Fork 861
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #29
- Loading branch information
Showing
3 changed files
with
86 additions
and
28 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
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,50 @@ | ||
import assert from 'power-assert' | ||
import Vue from 'vue' | ||
import locales from './fixture/locales' | ||
|
||
|
||
describe('component locales', () => { | ||
before((done) => { | ||
Object.keys(locales).forEach((lang) => { | ||
Vue.locale(lang, locales[lang]) | ||
}) | ||
Vue.config.lang = 'en' | ||
Vue.nextTick(done) | ||
}) | ||
|
||
let vm | ||
beforeEach((done) => { | ||
vm = new Vue({ | ||
el: document.createElement('div'), | ||
template: '<div><component1></component1></div>', | ||
components: { | ||
component1: { | ||
locales: { | ||
en: { | ||
foo: { | ||
bar: { | ||
buz: 'hello world' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
vm.$nextTick(done) | ||
}) | ||
|
||
describe('local', () => { | ||
it('should be translated', () => { | ||
const comp1 = vm.$children[0] // component1 | ||
assert(comp1.$t('foo.bar.buz') === 'hello world') | ||
}) | ||
}) | ||
|
||
describe('global', () => { | ||
it('should be translated', () => { | ||
const comp1 = vm.$children[0] // component1 | ||
assert(comp1.$t('message.hello') === 'the world') | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
|
@@ -10,3 +10,4 @@ Vue.use(plugin) | |
|
||
require('./i18n') | ||
require('./asset') | ||
require('./component') |