0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/test/unit/data/meta/cover_image_spec.js
Hannah Wolfe 7f1d3ebc07
Move tests from core to root (#11700)
- move all test files from core/test to test/
- updated all imports and other references
- all code inside of core/ is then application code
- tests are correctly at the root level
- consistent with other repos/projects

Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
2020-03-30 16:26:47 +01:00

72 lines
2.5 KiB
JavaScript

var should = require('should'),
getCoverImage = require('../../../../core/frontend/meta/cover_image');
describe('getCoverImage', function () {
it('should return absolute cover image url for home', function () {
var 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 () {
var 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 () {
var 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 () {
var 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 () {
var coverImageUrl = getCoverImage({
context: ['post'],
post: {}
});
should(coverImageUrl).equal(null);
});
it('should return null if author missing cover', function () {
var coverImageUrl = getCoverImage({
context: ['author'],
author: {}
});
should(coverImageUrl).equal(null);
});
it('should return null if home missing cover', function () {
var coverImageUrl = getCoverImage({
context: ['home'],
home: {}
});
should(coverImageUrl).equal(null);
});
});