Browse Source

Add test to i18n

pull/2385/head
Artur Arseniev 7 years ago
parent
commit
066244f483
  1. 60
      test/specs/i18n/index.js

60
test/specs/i18n/index.js

@ -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…
Cancel
Save