pgadmin4/web/regression/javascript/gettext_spec.js

52 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-03-16 09:27:55 -05:00
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
2019-01-02 04:24:12 -06:00
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
2017-03-16 09:27:55 -05:00
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
import gettext from 'sources/gettext';
import translations from 'translations';
describe('translate', function () {
describe('when there is no translation', function () {
it('returns the original string', function () {
2018-03-07 10:01:04 -06:00
expect(gettext('something else to be translated')).toEqual('something' +
' else to be translated');
});
describe('when there are substitutions', function () {
it('interpolates a substitution', function () {
expect(gettext('translate text for %s', 'Sarah')).toEqual('translate text for Sarah');
});
it('interpolates multiple substitutions', function () {
expect(
gettext('translate \'%s\' for %s', 'constitution', 'Sarah')
).toEqual('translate \'constitution\' for Sarah');
});
});
});
describe('when there is a translation', function () {
beforeEach(function () {
translations['something to be translated'] = 'etwas zum uebersetzen';
translations['another translation for %s'] = 'eine weitere Uebersetzung fuer %s';
});
it('returns the translation', function () {
expect(gettext('something to be translated')).toEqual('etwas zum uebersetzen');
});
describe('when there is a substitution', function () {
it('interpolates the substitution', function () {
expect(gettext('another translation for %s', 'Sarah'))
.toEqual('eine weitere Uebersetzung fuer Sarah');
});
});
});
});