mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
refs: https://github.com/TryGhost/Ghost/commit/e68cb8b31 - I found that some of the places we use rewire are totally unnecessary - Rewire seems to mess with coverage sometimes - It's also a code smell in general so I've ripped it out where possible
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
const should = require('should');
|
|
const sinon = require('sinon');
|
|
const registry = require('../../../../../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/');
|
|
});
|
|
});
|
|
});
|