Skip to content

Commit

Permalink
test: improve static catalog specs
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Jun 20, 2020
1 parent e6679aa commit 9feaff5
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion test/unit/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from '@lykmapipo/test-helpers';
import { stringify } from '@lykmapipo/common';

import {
withEnv,
Expand Down Expand Up @@ -243,7 +244,30 @@ describe('i18n', () => {
expect(locales).to.exist.and.be.an('object');
});

it('should use static catalog', () => {
// static catalog

it('should use environment static catalog', () => {
process.env.I18N_STATIC_CATALOG = stringify({
en: { salute: 'Hello' },
sw: { salute: 'Mambo' },
});

const i18n = configure({
reset: true,
});

expect(i18n.t('salute')).to.exist.and.be.equal('Hello');
expect(t('salute')).to.exist.and.be.equal('Hello');

expect(i18n.t({ phrase: 'salute', locale: 'sw' })).to.exist.and.be.equal(
'Mambo'
);
expect(t('salute', 'sw')).to.exist.and.be.equal('Mambo');

delete process.env.I18N_STATIC_CATALOG;
});

it('should use provide static catalog', () => {
const i18n = configure({
reset: true,
staticCatalog: {
Expand All @@ -253,9 +277,12 @@ describe('i18n', () => {
});

expect(i18n.t('salute')).to.exist.and.be.equal('Hello');
expect(t('salute')).to.exist.and.be.equal('Hello');

expect(i18n.t({ phrase: 'salute', locale: 'sw' })).to.exist.and.be.equal(
'Mambo'
);
expect(t('salute', 'sw')).to.exist.and.be.equal('Mambo');
});

after(() => {
Expand Down

0 comments on commit 9feaff5

Please sign in to comment.