0
Fork 0
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:
Hannah Wolfe 2021-05-06 19:38:01 +01:00
parent f63b4d8dcd
commit ccbb44bc67
No known key found for this signature in database
GPG key ID: 9F8C7532D0A6BA55

View file

@ -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();
}); });