mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-08 20:22:53 +03:00
7f1d3ebc07
- 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>
65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
var should = require('should'),
|
|
sinon = require('sinon'),
|
|
models = require('../../../../core/server/models'),
|
|
getKeywords = require('../../../../core/frontend/meta/keywords');
|
|
|
|
describe('getKeywords', function () {
|
|
before(function () {
|
|
models.init();
|
|
});
|
|
|
|
afterEach(function () {
|
|
sinon.restore();
|
|
});
|
|
|
|
it('should return tags as keywords if post has tags', function () {
|
|
var keywords = getKeywords({
|
|
post: {
|
|
tags: [
|
|
{name: 'one'},
|
|
{name: 'two'},
|
|
{name: 'three'}
|
|
]
|
|
}
|
|
});
|
|
should.deepEqual(keywords, ['one', 'two', 'three']);
|
|
});
|
|
|
|
it('should only return visible tags', function () {
|
|
var keywords = getKeywords({
|
|
post: {
|
|
tags: [
|
|
{name: 'one', visibility: 'public'},
|
|
{name: 'two', visibility: 'internal'},
|
|
{name: 'three'},
|
|
{name: 'four', visibility: 'internal'}
|
|
]
|
|
}
|
|
});
|
|
should.deepEqual(keywords, ['one', 'three']);
|
|
});
|
|
|
|
it('should return null if post has tags is empty array', function () {
|
|
var keywords = getKeywords({
|
|
post: {
|
|
tags: []
|
|
}
|
|
});
|
|
should.equal(keywords, null);
|
|
});
|
|
|
|
it('should return null if post has no tags', function () {
|
|
var keywords = getKeywords({
|
|
post: {}
|
|
});
|
|
should.equal(keywords, null);
|
|
});
|
|
|
|
it('should return null if not a post', function () {
|
|
var keywords = getKeywords({
|
|
author: {}
|
|
});
|
|
should.equal(keywords, null);
|
|
});
|
|
});
|