2020-04-29 18:44:27 +03:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
|
|
|
const rewire = require('rewire');
|
|
|
|
const 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/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|