mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +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!
73 lines
2.5 KiB
JavaScript
73 lines
2.5 KiB
JavaScript
const should = require('should');
|
|
const getCoverImage = require('../../../../core/frontend/meta/cover_image');
|
|
|
|
describe('getCoverImage', function () {
|
|
it('should return absolute cover image url for home', function () {
|
|
const coverImageUrl = getCoverImage({
|
|
context: ['home'],
|
|
home: {
|
|
cover_image: '/content/images/my-test-image.jpg'
|
|
}
|
|
});
|
|
coverImageUrl.should.not.equal('/content/images/my-test-image.jpg');
|
|
coverImageUrl.should.match(/\/content\/images\/my-test-image\.jpg$/);
|
|
});
|
|
|
|
it('should return absolute cover image url for author', function () {
|
|
const coverImageUrl = getCoverImage({
|
|
context: ['author'],
|
|
author: {
|
|
cover_image: '/content/images/my-test-image.jpg'
|
|
}
|
|
});
|
|
coverImageUrl.should.not.equal('/content/images/my-test-image.jpg');
|
|
coverImageUrl.should.match(/\/content\/images\/my-test-image\.jpg$/);
|
|
});
|
|
|
|
it('should return absolute image url for post', function () {
|
|
const coverImageUrl = getCoverImage({
|
|
context: ['post'],
|
|
post: {
|
|
feature_image: '/content/images/my-test-image.jpg'
|
|
}
|
|
});
|
|
coverImageUrl.should.not.equal('/content/images/my-test-image.jpg');
|
|
coverImageUrl.should.match(/\/content\/images\/my-test-image\.jpg$/);
|
|
});
|
|
|
|
it('should return absolute image url for AMP post', function () {
|
|
const coverImageUrl = getCoverImage({
|
|
context: ['amp', 'post'],
|
|
post: {
|
|
feature_image: '/content/images/my-test-image.jpg'
|
|
}
|
|
});
|
|
coverImageUrl.should.not.equal('/content/images/my-test-image.jpg');
|
|
coverImageUrl.should.match(/\/content\/images\/my-test-image\.jpg$/);
|
|
});
|
|
|
|
it('should return null if missing image', function () {
|
|
const coverImageUrl = getCoverImage({
|
|
context: ['post'],
|
|
post: {}
|
|
});
|
|
should(coverImageUrl).equal(null);
|
|
});
|
|
|
|
it('should return null if author missing cover', function () {
|
|
const coverImageUrl = getCoverImage({
|
|
context: ['author'],
|
|
author: {}
|
|
});
|
|
should(coverImageUrl).equal(null);
|
|
});
|
|
|
|
it('should return null if home missing cover', function () {
|
|
const coverImageUrl = getCoverImage({
|
|
context: ['home'],
|
|
home: {}
|
|
});
|
|
should(coverImageUrl).equal(null);
|
|
});
|
|
});
|