mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-13 14:39:52 +03:00
06d91ce046
closes #6186 - Refactored ghost head helper to use the new metadata functions. - Fix issue where tag should output description if missing meta description. - Add test for tag description. - Updated tests to look for author urls with a tailing backslash - Fix author to output meta description first and then bio if missing.
75 lines
2.4 KiB
JavaScript
75 lines
2.4 KiB
JavaScript
/*globals describe, it*/
|
|
var getMetaDescription = require('../../../server/data/meta/description');
|
|
|
|
describe('getMetaDescription', function () {
|
|
it('should return meta_description if on data root', function () {
|
|
var description = getMetaDescription({
|
|
meta_description: 'My test description.'
|
|
});
|
|
description.should.equal('My test description.');
|
|
});
|
|
|
|
it('should return empty string if on root context contains paged', function () {
|
|
var description = getMetaDescription({}, {
|
|
context: ['paged']
|
|
});
|
|
description.should.equal('');
|
|
});
|
|
|
|
it('should return data author bio if on root context contains author', function () {
|
|
var description = getMetaDescription({
|
|
author: {
|
|
bio: 'Just some hack building code to make the world better.'
|
|
}
|
|
}, {
|
|
context: ['author']
|
|
});
|
|
description.should.equal('Just some hack building code to make the world better.');
|
|
});
|
|
|
|
it('should return data tag meta description if on root context contains tag', function () {
|
|
var description = getMetaDescription({
|
|
tag: {
|
|
meta_description: 'Best tag ever!'
|
|
}
|
|
}, {
|
|
context: ['tag']
|
|
});
|
|
description.should.equal('Best tag ever!');
|
|
});
|
|
|
|
it('should return data tag description if no meta description for tag', function () {
|
|
var description = getMetaDescription({
|
|
tag: {
|
|
meta_description: '',
|
|
description: 'The normal description'
|
|
}
|
|
}, {
|
|
context: ['tag']
|
|
});
|
|
description.should.equal('The normal description');
|
|
});
|
|
|
|
it('should return data post meta description if on root context contains post', function () {
|
|
var description = getMetaDescription({
|
|
post: {
|
|
meta_description: 'Best post ever!'
|
|
}
|
|
}, {
|
|
context: ['post']
|
|
});
|
|
description.should.equal('Best post ever!');
|
|
});
|
|
|
|
it('should return data post meta description if on root context contains page', function () {
|
|
var description = getMetaDescription({
|
|
post: {
|
|
meta_description: 'Best page ever!'
|
|
}
|
|
}, {
|
|
context: ['page']
|
|
});
|
|
description.should.equal('Best page ever!');
|
|
});
|
|
});
|