mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
22e13acd65
- All var declarations are now const or let as per ES6 - All comma-separated lists / chained declarations are now one declaration per line - This is for clarity/readability but also made running the var-to-const/let switch smoother - ESLint rules updated to match How this was done: - npm install -g jscodeshift - git clone https://github.com/cpojer/js-codemod.git - git clone git@github.com:TryGhost/Ghost.git shallow-ghost - cd shallow-ghost - jscodeshift -t ../js-codemod/transforms/unchain-variables.js . -v=2 - jscodeshift -t ../js-codemod/transforms/no-vars.js . -v=2 - yarn - yarn test - yarn lint / fix various lint errors (almost all indent) by opening files and saving in vscode - grunt test-regression - sorted!
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
const should = require('should');
|
|
const sinon = require('sinon');
|
|
const rewire = require('rewire');
|
|
const configUtils = require('../../../utils/configUtils');
|
|
const rssCache = rewire('../../../../core/frontend/services/rss/cache');
|
|
|
|
describe('RSS: Cache', function () {
|
|
let generateSpy;
|
|
let generateFeedReset;
|
|
|
|
afterEach(function () {
|
|
configUtils.restore();
|
|
sinon.restore();
|
|
generateFeedReset();
|
|
});
|
|
|
|
beforeEach(function () {
|
|
configUtils.set({url: 'http://my-ghost-blog.com'});
|
|
|
|
generateSpy = sinon.spy(rssCache.__get__('generateFeed'));
|
|
generateFeedReset = rssCache.__set__('generateFeed', generateSpy);
|
|
});
|
|
|
|
it('should not rebuild xml for same data and url', function (done) {
|
|
const data = {
|
|
title: 'Test Title',
|
|
description: 'Testing Desc',
|
|
posts: [],
|
|
meta: {pagination: {pages: 1}}
|
|
};
|
|
let xmlData1;
|
|
|
|
rssCache.getXML('/rss/', data)
|
|
.then(function (_xmlData) {
|
|
xmlData1 = _xmlData;
|
|
|
|
// We should have called generateFeed
|
|
generateSpy.callCount.should.eql(1);
|
|
|
|
// Call RSS again to check that we didn't rebuild
|
|
return rssCache.getXML('/rss/', data);
|
|
})
|
|
.then(function (xmlData2) {
|
|
// Assertions
|
|
|
|
// We should not have called generateFeed again
|
|
generateSpy.callCount.should.eql(1);
|
|
|
|
// The data should be identical, no changing lastBuildDate
|
|
xmlData1.should.equal(xmlData2);
|
|
|
|
done();
|
|
})
|
|
.catch(done);
|
|
});
|
|
});
|