Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows i18n en lang override #1885

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/__tests__/i18n.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Immutable from 'immutable';
import flatten from 'flat';

import enDictionary from '../i18n/en';
import esDictionary from '../i18n/es';

import * as sync from '../sync';
import * as l from '../core/index';

describe('i18n', () => {
let syncSpy;
let langSpy;

beforeEach(() => {
syncSpy = jest.spyOn(sync, 'default');

langSpy = jest.spyOn(l.ui, 'language').mockImplementation(() => {
return 'en';
});
});

afterEach(() => {
syncSpy.mockRestore();
langSpy.mockRestore();
});

describe('load i18n configuration', () => {
it('should have a defaultDictionary', () => {
const i18n = require('../i18n');

// We need to initialize the state
var m = Immutable.fromJS({});

// Initialize i18n.
const initialized = i18n.initI18n(m);

let language = flatten(initialized.getIn(['i18n', 'strings']).toJS());
const en = flatten(enDictionary);

expect(language).toEqual(en);
});
});

describe('when en language is selected', () => {
it('should allow check for external en dictionaries', () => {
const i18n = require('../i18n');

i18n.initI18n(Immutable.fromJS({}));
expect(syncSpy).toHaveBeenCalledTimes(1);
});
});
});
2 changes: 0 additions & 2 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ function registerLanguageDictionary(language, dictionary) {
languageDictionaries[language] = Immutable.fromJS(dictionary);
}

registerLanguageDictionary('en', enDictionary);

preload({
method: 'registerLanguageDictionary',
cb: registerLanguageDictionary
Expand Down
7 changes: 5 additions & 2 deletions test/captcha.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ describe('captcha', function() {
this.lock.hide();
});

it('should show the captcha input', function() {
expect(h.qInput(this.lock, 'captcha', false)).to.be.ok();
it('should show the captcha input', function(done) {
setTimeout(() => {
expect(h.qInput(this.lock, 'captcha', false)).to.be.ok();
done();
}, 500);
});

it('should require another challenge when clicking the refresh button', function(done) {
Expand Down