# All files / infrastructure/i18n i18n.engine.spec.ts

100% Statements 19/19
100% Branches 0/0
100% Functions 7/7
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    311x

    1x

    1x
    1x
    1x

    1x
    1x
    1x

    1x
    1x
    1x

    1x
    1x
    1x

    1x
    1x
    1x

     const expect = require('chai').expect;

    import I18nEngine from './i18n.engine';

    describe('Infrastructure - Setup i18n and use it', () => {
        before(async () => {
            return I18nEngine.init('fr-FR');
        });

        it('should translate key', () => {
            const keyTranslated = I18nEngine.translate('controllers');
            expect(keyTranslated).equal('Contrôleurs');
        });

        it('should give language support information', () => {
            expect(I18nEngine.supportLanguage('sv-SV')).to.be.false;
            expect(I18nEngine.supportLanguage('fr-FR')).to.be.true;
        });
    });

    describe('Setup i18n without supported language and fallback', () => {
        before(async () => {
            return I18nEngine.init('sv-SV');
        });

        it('should translate key with fallback', () => {
            const keyTranslated = I18nEngine.translate('controllers');
            expect(keyTranslated).equal('Controllers');
        });
    });