2018-06-21 21:18:29 +03:00
|
|
|
const should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
|
|
|
rewire = require('rewire'),
|
2020-03-30 18:26:47 +03:00
|
|
|
registry = rewire('../../../../core/frontend/services/routing/registry');
|
2018-06-21 21:18:29 +03:00
|
|
|
|
|
|
|
describe('UNIT: services/routing/registry', function () {
|
|
|
|
let getRssUrlStub;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
getRssUrlStub = sinon.stub();
|
2018-06-21 21:18:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2018-06-21 21:18:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
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',
|
2019-01-21 19:53:44 +03:00
|
|
|
getRssUrl: sinon.stub().returns('/podcast/rss/')
|
2018-06-21 21:18:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
registry.getRssUrl().should.eql('/podcast/rss/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('single collection, no index collection, rss disabled', function () {
|
|
|
|
registry.setRouter('CollectionRouter', {
|
|
|
|
name: 'CollectionRouter',
|
|
|
|
routerName: 'podcast',
|
2019-01-21 19:53:44 +03:00
|
|
|
getRssUrl: sinon.stub().returns(null)
|
2018-06-21 21:18:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
should.not.exist(registry.getRssUrl());
|
|
|
|
});
|
|
|
|
|
|
|
|
it('index collection', function () {
|
|
|
|
registry.setRouter('CollectionRouter', {
|
|
|
|
name: 'CollectionRouter',
|
|
|
|
routerName: 'podcast',
|
2019-01-21 19:53:44 +03:00
|
|
|
getRssUrl: sinon.stub().returns('/podcast/rss/')
|
2018-06-21 21:18:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
registry.setRouter('CollectionRouter', {
|
|
|
|
name: 'CollectionRouter',
|
|
|
|
routerName: 'index',
|
2019-01-21 19:53:44 +03:00
|
|
|
getRssUrl: sinon.stub().returns('/rss/')
|
2018-06-21 21:18:29 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
registry.getRssUrl().should.eql('/rss/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|