Ghost/core/test/unit/helpers/date_spec.js
Naz Gargol a9050f68ea
🔥 Removed V1 code/references in frontend helpers/meta layers (#11080)
no issue

- Removed deprecated 'blog' reference from frontend data. The alias (site->blog) stays till next version (v4) as it's not leaving much of technical debt but would ease the migration process for anybody still using it. 
- The follow up to this is substitute of all references to `options.data.blog` with `options.data.site` in "frontend"
- Fixed test utils helper to use `site` instead of `blog`
- Removed 0.1 flag checks in {{get}} helper
- Removed user aliasing from {{get}} helper
- Removed unused translation for {{get}} helper
- Added a note to excerpt changes in metadata for future reference
- Removed page alias used in description helper. The mix of page context with post object in the metadata was only possible in v0.1
- Changed mock in ghost_head helper to use v2
- Removed unneeded test for body class helper
2019-09-10 11:37:04 +02:00

64 lines
2.0 KiB
JavaScript

var should = require('should'),
// Stuff we are testing
helpers = require('../../../frontend/helpers'),
moment = require('moment-timezone');
describe('{{date}} helper', function () {
it('creates properly formatted date strings', function () {
var testDates = [
'2013-12-31T11:28:58.593+02:00',
'2014-01-01T01:28:58.593+11:00',
'2014-02-20T01:28:58.593-04:00',
'2014-03-01T01:28:58.593+00:00'
],
timezones = 'Europe/Dublin',
format = 'MMM Do, YYYY',
context = {
hash: {
format: format
},
data: {
site: {
timezone: 'Europe/Dublin'
}
}
};
testDates.forEach(function (d) {
var rendered = helpers.date.call({published_at: d}, context);
should.exist(rendered);
String(rendered).should.equal(moment(d).tz(timezones).format(format));
});
});
it('creates properly formatted time ago date strings', function () {
var testDates = [
'2013-12-31T23:58:58.593+02:00',
'2014-01-01T00:28:58.593+11:00',
'2014-11-20T01:28:58.593-04:00',
'2014-03-01T01:28:58.593+00:00'
],
timezones = 'Europe/Dublin',
timeNow = moment().tz('Europe/Dublin'),
context = {
hash: {
timeago: true
},
data: {
site: {
timezone: 'Europe/Dublin'
}
}
};
testDates.forEach(function (d) {
var rendered = helpers.date.call({published_at: d}, context);
should.exist(rendered);
String(rendered).should.equal(moment(d).tz(timezones).from(timeNow));
});
});
});