mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
22e13acd65
- All var declarations are now const or let as per ES6 - All comma-separated lists / chained declarations are now one declaration per line - This is for clarity/readability but also made running the var-to-const/let switch smoother - ESLint rules updated to match How this was done: - npm install -g jscodeshift - git clone https://github.com/cpojer/js-codemod.git - git clone git@github.com:TryGhost/Ghost.git shallow-ghost - cd shallow-ghost - jscodeshift -t ../js-codemod/transforms/unchain-variables.js . -v=2 - jscodeshift -t ../js-codemod/transforms/no-vars.js . -v=2 - yarn - yarn test - yarn lint / fix various lint errors (almost all indent) by opening files and saving in vscode - grunt test-regression - sorted!
69 lines
1.9 KiB
JavaScript
69 lines
1.9 KiB
JavaScript
const should = require('should');
|
|
|
|
// Stuff we are testing
|
|
const helpers = require('../../../core/frontend/helpers');
|
|
|
|
const moment = require('moment-timezone');
|
|
|
|
describe('{{date}} helper', function () {
|
|
it('creates properly formatted date strings', function () {
|
|
const 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'
|
|
];
|
|
|
|
const timezones = 'Europe/Dublin';
|
|
const format = 'MMM Do, YYYY';
|
|
|
|
const context = {
|
|
hash: {
|
|
format: format
|
|
},
|
|
data: {
|
|
site: {
|
|
timezone: 'Europe/Dublin'
|
|
}
|
|
}
|
|
};
|
|
|
|
testDates.forEach(function (d) {
|
|
const 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 () {
|
|
const 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'
|
|
];
|
|
|
|
const timezones = 'Europe/Dublin';
|
|
const timeNow = moment().tz('Europe/Dublin');
|
|
|
|
const context = {
|
|
hash: {
|
|
timeago: true
|
|
},
|
|
data: {
|
|
site: {
|
|
timezone: 'Europe/Dublin'
|
|
}
|
|
}
|
|
};
|
|
|
|
testDates.forEach(function (d) {
|
|
const rendered = helpers.date.call({published_at: d}, context);
|
|
|
|
should.exist(rendered);
|
|
String(rendered).should.equal(moment(d).tz(timezones).from(timeNow));
|
|
});
|
|
});
|
|
});
|