Ghost/test/unit/frontend/services/routing/registry.test.js
Hannah Wolfe 95d27e7f58
Moved frontend unit tests into their own folder
- this is a small part of a bit of cleanup of our test files
- the goal is to make the existing tests clearer with a view to making it easier to write more tests
- this makes the test structure follow the codebase structure more closely
- eventually we will colocate the frontend tests with the frontend code
2021-10-06 11:58:29 +01:00

59 lines
1.8 KiB
JavaScript

const should = require('should');
const sinon = require('sinon');
const rewire = require('rewire');
const registry = rewire('../../../../../core/frontend/services/routing/registry');
describe('UNIT: services/routing/registry', function () {
let getRssUrlStub;
beforeEach(function () {
getRssUrlStub = sinon.stub();
});
afterEach(function () {
sinon.restore();
});
describe('fn: getRssUrl', function () {
it('no url available', function () {
should.not.exist(registry.getRssUrl());
});
it('single collection, no index collection', function () {
registry.setRouter('CollectionRouter', {
name: 'CollectionRouter',
routerName: 'podcast',
getRssUrl: sinon.stub().returns('/podcast/rss/')
});
registry.getRssUrl().should.eql('/podcast/rss/');
});
it('single collection, no index collection, rss disabled', function () {
registry.setRouter('CollectionRouter', {
name: 'CollectionRouter',
routerName: 'podcast',
getRssUrl: sinon.stub().returns(null)
});
should.not.exist(registry.getRssUrl());
});
it('index collection', function () {
registry.setRouter('CollectionRouter', {
name: 'CollectionRouter',
routerName: 'podcast',
getRssUrl: sinon.stub().returns('/podcast/rss/')
});
registry.setRouter('CollectionRouter', {
name: 'CollectionRouter',
routerName: 'index',
getRssUrl: sinon.stub().returns('/rss/')
});
registry.getRssUrl().should.eql('/rss/');
});
});
});