mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Added fake logging to i18n tests
- without this we splurge random info out into the test results, which is undesirable 🙈
This commit is contained in:
parent
f63b4d8dcd
commit
ccbb44bc67
1 changed files with 10 additions and 5 deletions
|
@ -3,20 +3,25 @@ const sinon = require('sinon');
|
||||||
|
|
||||||
const I18n = require('../../../core/shared/i18n').I18n;
|
const I18n = require('../../../core/shared/i18n').I18n;
|
||||||
|
|
||||||
|
const logging = {
|
||||||
|
warn: sinon.stub(),
|
||||||
|
error: sinon.stub()
|
||||||
|
};
|
||||||
|
|
||||||
describe('I18n Class Behaviour', function () {
|
describe('I18n Class Behaviour', function () {
|
||||||
it('defaults to en', function () {
|
it('defaults to en', function () {
|
||||||
const i18n = new I18n();
|
const i18n = new I18n({logging});
|
||||||
i18n.locale().should.eql('en');
|
i18n.locale().should.eql('en');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can have a different locale set', function () {
|
it('can have a different locale set', function () {
|
||||||
const i18n = new I18n({locale: 'fr'});
|
const i18n = new I18n({locale: 'fr', logging});
|
||||||
i18n.locale().should.eql('fr');
|
i18n.locale().should.eql('fr');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('file loading behaviour', function () {
|
describe('file loading behaviour', function () {
|
||||||
it('will fallback to en file correctly without changing locale', function () {
|
it('will fallback to en file correctly without changing locale', function () {
|
||||||
const i18n = new I18n({locale: 'fr'});
|
const i18n = new I18n({locale: 'fr', logging});
|
||||||
|
|
||||||
let fileSpy = sinon.spy(i18n, '_readTranslationsFile');
|
let fileSpy = sinon.spy(i18n, '_readTranslationsFile');
|
||||||
|
|
||||||
|
@ -36,7 +41,7 @@ describe('I18n Class Behaviour', function () {
|
||||||
let i18n;
|
let i18n;
|
||||||
|
|
||||||
beforeEach(function initBasicI18n() {
|
beforeEach(function initBasicI18n() {
|
||||||
i18n = new I18n();
|
i18n = new I18n({logging});
|
||||||
sinon.stub(i18n, '_loadStrings').returns(fakeStrings);
|
sinon.stub(i18n, '_loadStrings').returns(fakeStrings);
|
||||||
i18n.init();
|
i18n.init();
|
||||||
});
|
});
|
||||||
|
@ -65,7 +70,7 @@ describe('I18n Class Behaviour', function () {
|
||||||
let i18n;
|
let i18n;
|
||||||
|
|
||||||
beforeEach(function initFulltextI18n() {
|
beforeEach(function initFulltextI18n() {
|
||||||
i18n = new I18n({stringMode: 'fulltext'});
|
i18n = new I18n({stringMode: 'fulltext', logging});
|
||||||
sinon.stub(i18n, '_loadStrings').returns(fakeStrings);
|
sinon.stub(i18n, '_loadStrings').returns(fakeStrings);
|
||||||
i18n.init();
|
i18n.init();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue