Ghost/test/unit/helpers/lang_spec.js
Matt Hanley b4140d4310
Updated default format for date helper to locale-based date string (#12733)
refs https://github.com/TryGhost/Casper/pull/741
closes https://github.com/TryGhost/Team/issues/524

- Use a local-based format as the default format as suggested in https://github.com/TryGhost/Casper/pull/741
- reworked the helper to be easier to read and follow the different use cases
- introduced setting and resetting locale in tests via settingsCache and themei18n
- updated tests to cover more cases e.g. passing a date, this.published_at and no date
- added validation for user inputted dates because they could literally be anything

Co-authored-by: Hannah Wolfe <erisds@gmail.com>
2021-03-05 13:35:31 +00:00

25 lines
755 B
JavaScript

const should = require('should');
const settingsCache = require('../../../core/server/services/settings/cache');
const helpers = require('../../../core/frontend/helpers');
const proxy = require('../../../core/frontend/services/proxy');
describe('{{lang}} helper', function () {
beforeEach(function () {
settingsCache.set('lang', {value: 'en'});
proxy.themeI18n._loadLocale();
});
afterEach(function () {
settingsCache.shutdown();
proxy.themeI18n._loadLocale();
});
it('returns correct language tag', function () {
let expected = proxy.themeI18n.locale();
let rendered = helpers.lang.call();
should.exist(rendered);
rendered.string.should.equal(expected);
});
});