mirror of https://github.com/artf/grapesjs.git
1 changed files with 60 additions and 0 deletions
@ -0,0 +1,60 @@ |
|||
import I18n from 'i18n'; |
|||
|
|||
describe('I18n', () => { |
|||
describe('Main', () => { |
|||
let em; |
|||
let obj; |
|||
let editor; |
|||
|
|||
beforeEach(() => { |
|||
obj = I18n(); |
|||
obj.init(); |
|||
}); |
|||
|
|||
test('Object exists', () => { |
|||
expect(obj).toBeTruthy(); |
|||
}); |
|||
|
|||
test('getConfig method', () => { |
|||
expect(obj.getConfig()).toBeTruthy(); |
|||
}); |
|||
|
|||
test('Default local', () => { |
|||
expect(obj.getLocale()).toBeTruthy(); |
|||
}); |
|||
|
|||
test('setLocale and getLocale methods', () => { |
|||
const localeBefore = obj.getLocale(); |
|||
const localeNew = `${localeBefore}2`; |
|||
obj.setLocale(localeNew); |
|||
expect(obj.getLocale()).toBe(localeNew); |
|||
}); |
|||
|
|||
test('Default messages', () => { |
|||
expect(obj.getMessages()).toBeTruthy(); |
|||
}); |
|||
|
|||
test('setMessages method', () => { |
|||
const set1 = { en: { msg1: 'Msg 1' } }; |
|||
obj.setMessages(set1); |
|||
expect(obj.getMessages()).toEqual(set1); |
|||
const set2 = { en: { msg2: 'Msg 2' } }; |
|||
obj.setMessages(set2); |
|||
expect(obj.getMessages()).toEqual(set2); |
|||
}); |
|||
|
|||
test('addMessages method', () => { |
|||
const set1 = { en: { msg1: 'Msg 1', msg2: 'Msg 2' } }; |
|||
obj.setMessages(set1); |
|||
const set2 = { |
|||
en: { msg2: 'Msg 2 up', msg3: 'Msg 3' }, |
|||
it: { msg1: 'Msg 1' } |
|||
}; |
|||
obj.addMessages(set2); |
|||
expect(obj.getMessages()).toEqual({ |
|||
en: { msg1: 'Msg 1', msg2: 'Msg 2 up', msg3: 'Msg 3' }, |
|||
it: { msg1: 'Msg 1' } |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
Loading…
Reference in new issue