0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Removed 2 test files that weren't deleted when moved

refs: 95d27e7f5

- My IDE is messing me about today, I moved these two files into test/unit/frontend/services in 95d27e7f5
This commit is contained in:
Hannah Wolfe 2021-10-06 12:16:37 +01:00
parent 9e96b04542
commit f5f24d9cbc
No known key found for this signature in database
GPG key ID: 9F8C7532D0A6BA55
2 changed files with 0 additions and 225 deletions

View file

@ -1,101 +0,0 @@
const should = require('should');
const sinon = require('sinon');
const Promise = require('bluebird');
const rssCache = require('../../../../../core/frontend/services/rss/cache');
const renderer = require('../../../../../core/frontend/services/rss/renderer');
describe('RSS: Renderer', function () {
let rssCacheStub;
let res;
let baseUrl;
beforeEach(function () {
rssCacheStub = sinon.stub(rssCache, 'getXML');
res = {
locals: {},
set: sinon.stub(),
send: sinon.spy()
};
baseUrl = '/rss/';
});
afterEach(function () {
sinon.restore();
});
it('calls the cache and attempts to render, even without data', function (done) {
rssCacheStub.returns(new Promise.resolve('dummyxml'));
renderer.render(res, baseUrl).then(function () {
rssCacheStub.calledOnce.should.be.true();
rssCacheStub.firstCall.args.should.eql(['/rss/', {}]);
res.set.calledOnce.should.be.true();
res.set.calledWith('Content-Type', 'text/xml; charset=UTF-8').should.be.true();
res.send.calledOnce.should.be.true();
res.send.calledWith('dummyxml').should.be.true();
done();
}).catch(done);
});
it('correctly merges locals into empty data before rendering', function (done) {
rssCacheStub.returns(new Promise.resolve('dummyxml'));
res.locals = {foo: 'bar'};
renderer.render(res, baseUrl).then(function () {
rssCacheStub.calledOnce.should.be.true();
rssCacheStub.firstCall.args.should.eql(['/rss/', {foo: 'bar'}]);
res.set.calledOnce.should.be.true();
res.set.calledWith('Content-Type', 'text/xml; charset=UTF-8').should.be.true();
res.send.calledOnce.should.be.true();
res.send.calledWith('dummyxml').should.be.true();
done();
}).catch(done);
});
it('correctly merges locals into non-empty data before rendering', function (done) {
rssCacheStub.returns(new Promise.resolve('dummyxml'));
res.locals = {foo: 'bar'};
const data = {foo: 'baz', fizz: 'buzz'};
renderer.render(res, baseUrl, data).then(function () {
rssCacheStub.calledOnce.should.be.true();
rssCacheStub.firstCall.args.should.eql(['/rss/', {foo: 'baz', fizz: 'buzz'}]);
res.set.calledOnce.should.be.true();
res.set.calledWith('Content-Type', 'text/xml; charset=UTF-8').should.be.true();
res.send.calledOnce.should.be.true();
res.send.calledWith('dummyxml').should.be.true();
done();
}).catch(done);
});
it('does nothing if it gets an error', function (done) {
rssCacheStub.returns(new Promise.reject(new Error('Fake Error')));
renderer.render(res, baseUrl).then(function () {
done('This should have errored');
}).catch(function (err) {
err.message.should.eql('Fake Error');
rssCacheStub.calledOnce.should.be.true();
rssCacheStub.firstCall.args.should.eql(['/rss/', {}]);
res.set.called.should.be.false();
res.send.called.should.be.false();
done();
});
});
});

View file

@ -1,124 +0,0 @@
const should = require('should');
const sinon = require('sinon');
// Stuff we are testing
const events = require('../../../../../core/server/lib/common/events');
const SiteMapManager = require('../../../../../core/frontend/services/sitemap/manager');
const PostGenerator = require('../../../../../core/frontend/services/sitemap/post-generator');
const PageGenerator = require('../../../../../core/frontend/services/sitemap/page-generator');
const TagGenerator = require('../../../../../core/frontend/services/sitemap/tag-generator');
const UserGenerator = require('../../../../../core/frontend/services/sitemap/user-generator');
const IndexGenerator = require('../../../../../core/frontend/services/sitemap/index-generator');
describe('Unit: sitemap/manager', function () {
let eventsToRemember;
const makeStubManager = function () {
let posts;
let pages;
let tags;
let authors;
let index;
index = new IndexGenerator();
posts = new PostGenerator();
pages = new PageGenerator();
tags = new TagGenerator();
authors = new UserGenerator();
return new SiteMapManager({posts: posts, pages: pages, tags: tags, authors: authors});
};
beforeEach(function () {
eventsToRemember = {};
sinon.stub(events, 'on').callsFake(function (eventName, callback) {
eventsToRemember[eventName] = callback;
});
sinon.stub(PostGenerator.prototype, 'getXml');
sinon.stub(PostGenerator.prototype, 'addUrl');
sinon.stub(PostGenerator.prototype, 'removeUrl');
sinon.stub(IndexGenerator.prototype, 'getXml');
});
afterEach(function () {
sinon.restore();
});
describe('SiteMapManager', function () {
let manager;
let fake;
beforeEach(function () {
manager = makeStubManager();
fake = sinon.stub();
});
it('create SiteMapManager with defaults', function () {
const siteMapManager = new SiteMapManager();
should.exist(siteMapManager.posts);
should.exist(siteMapManager.pages);
should.exist(siteMapManager.users);
should.exist(siteMapManager.tags);
});
it('can create a SiteMapManager instance', function () {
should.exist(manager);
Object.keys(eventsToRemember).length.should.eql(4);
should.exist(eventsToRemember['url.added']);
should.exist(eventsToRemember['url.removed']);
should.exist(eventsToRemember['router.created']);
should.exist(eventsToRemember['routers.reset']);
});
describe('trigger url events', function () {
it('url.added', function () {
eventsToRemember['url.added']({
url: {
relative: '/test/',
absolute: 'https://myblog.com/test/'
},
resource: {
config: {
type: 'posts'
},
data: {}
}
});
PostGenerator.prototype.addUrl.calledOnce.should.be.true();
});
it('url.removed', function () {
eventsToRemember['url.removed']({
url: {
relative: '/test/',
absolute: 'https://myblog.com/test/'
},
resource: {
config: {
type: 'posts'
},
data: {}
}
});
PostGenerator.prototype.removeUrl.calledOnce.should.be.true();
});
});
it('fn: getSiteMapXml', function () {
PostGenerator.prototype.getXml.returns('xml');
manager.getSiteMapXml('posts').should.eql('xml');
PostGenerator.prototype.getXml.calledOnce.should.be.true();
});
it('fn: getIndexXml', function () {
IndexGenerator.prototype.getXml.returns('xml');
manager.getIndexXml().should.eql('xml');
IndexGenerator.prototype.getXml.calledOnce.should.be.true();
});
});
});