0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/test/unit/frontend/services/data/checks.test.js
Hannah Wolfe e9d6f61029
Moved checks into frontend data service
refs: https://github.com/TryGhost/Ghost/commit/11867ab43

- These checks live in the wrong place. They are mostly a frontend thing
- The only server place they were used was slack and that was fixed in 11867ab43
- Moving these to the frontend they fit neatly into the frontend data service
2022-04-05 15:23:00 +01:00

43 lines
1.8 KiB
JavaScript

const should = require('should');
const {checks} = require('../../../../../core/frontend/services/data');
describe('Checks', function () {
it('methods', function () {
Object.keys(checks).should.eql([
'isPost',
'isTag',
'isUser',
'isNav'
]);
});
it('isPost', function () {
checks.isPost({}).should.eql(false);
checks.isPost({title: 'Test'}).should.eql(false);
checks.isPost({title: 'Test', slug: 'test'}).should.eql(false);
checks.isPost({title: 'Test', slug: 'test', html: ''}).should.eql(true);
});
it('isTag', function () {
checks.isTag({}).should.eql(false);
checks.isTag({name: 'Test'}).should.eql(false);
checks.isTag({name: 'Test', slug: 'test'}).should.eql(false);
checks.isTag({name: 'Test', slug: 'test', description: ''}).should.eql(false);
checks.isTag({name: 'Test', slug: 'test', description: '', feature_image: ''}).should.eql(true);
});
it('isUser', function () {
checks.isUser({}).should.eql(false);
checks.isUser({bio: 'Test'}).should.eql(false);
checks.isUser({bio: 'Test', website: 'test'}).should.eql(false);
checks.isUser({bio: 'Test', website: 'test', profile_image: ''}).should.eql(false);
checks.isUser({bio: 'Test', website: 'test', profile_image: '', location: ''}).should.eql(true);
});
it('isNav', function () {
checks.isNav({}).should.eql(false);
checks.isNav({label: 'Test'}).should.eql(false);
checks.isNav({label: 'Test', slug: 'test'}).should.eql(false);
checks.isNav({label: 'Test', slug: 'test', url: ''}).should.eql(false);
checks.isNav({label: 'Test', slug: 'test', url: '', current: false}).should.eql(true);
});
});