0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/test/unit/metadata/description_spec.js
JT Turner 1f4c01d207 Started moving meta data fetching to functions.
issue #6186
- Moved asset helper logic to a asset url function.
- Created author image function to be used in ghost_head helper.
- Created author url function to be used in the ghost_head helper.
- Created canonical url function to be used in the ghost_head helper.
- Moved meta_description helper logic to a function.
- Moved excerpt helper logic to a function.
- Created an index in data/meta to be used in ghost_head helper to get all data.
- Created keyword function to be used in the ghost_head helper.
- Created modified data function to be used in the ghost_head helper.
- Created next url function to be used in the ghost_head helper.
- Created ogType function to be used in the ghost_head helper.
- Created previous url function to be used in the ghost_head helper.
- Created published data function to be used in the ghost_head helper.
- Created rss url function to be used in the ghost_head helper.
- Created schema function to be used in the ghost_head helper.
- Created structured data function to be used in the ghost_head helper.
- Moved meta_title helper logic to a title function.
- Moved url helper logic to a url function.
- Wrote tests for all the new functions

This is just the first step. I plan on refactoring the ghost head to use these new functions.
2016-01-23 13:58:21 -08:00

62 lines
2 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 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!');
});
});