Browse Source

Up tests

pull/5796/head
Artur Arseniev 2 years ago
parent
commit
77b9ad9f6a
  1. 2
      src/i18n/index.ts
  2. 11
      test/specs/i18n/index.ts

2
src/i18n/index.ts

@ -89,7 +89,7 @@ export default class I18nModule extends Module<I18nConfig & { stylePrefix?: stri
* i18n.getMessages('en');
* // -> { hello: '...' }
*/
getMessages(lang: string, opts = {}) {
getMessages(lang?: string, opts = {}) {
const messages = this.config.messages!;
lang && !messages[lang] && this._debug(`'${lang}' i18n lang not found`, opts);
return lang ? messages[lang] : messages;

11
test/specs/i18n/index.js → test/specs/i18n/index.ts

@ -1,13 +1,14 @@
import I18n from 'i18n';
import Editor from 'editor';
import I18n from '../../../src/i18n';
import Editor from '../../../src/editor';
import { I18nConfig } from '../../../src/i18n/config';
describe('I18n', () => {
describe('Main', () => {
let obj;
let obj: I18n;
let editor = new Editor();
let em = editor.getModel();
const newModuleWithConfig = i18n => {
const newModuleWithConfig = (i18n: I18nConfig) => {
const editor = new Editor({ i18n });
const em = editor.getModel();
return new I18n(em);
@ -36,7 +37,7 @@ describe('I18n', () => {
obj = newModuleWithConfig({
locale,
localeFallback,
detectLocale: 0,
detectLocale: false,
messages: {
en: { msg },
},
Loading…
Cancel
Save