mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
dbafaf7205
- Moved handle-image-sizes from shared to site as it is not shared - This file is only used in one place, this updates the code structure to reflect this - This is one of many similar changes needed to make it easier to refactor to the existing setup
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
const should = require('should');
|
|
const handleImageSizes = require('../../../../../core/server/web/site/middleware/handle-image-sizes.js');
|
|
|
|
// @TODO make these tests lovely and non specific to implementation
|
|
describe('handleImageSizes middleware', function () {
|
|
it('calls next immediately if the url does not match /size/something/', function (done) {
|
|
const fakeReq = {
|
|
url: '/size/something'
|
|
};
|
|
// CASE: second thing middleware does is try to match to a regex
|
|
fakeReq.url.match = function () {
|
|
throw new Error('Should have exited immediately');
|
|
};
|
|
handleImageSizes(fakeReq, {}, function next() {
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('calls next immediately if the url does not match /size/something/', function (done) {
|
|
const fakeReq = {
|
|
url: '/url/whatever/'
|
|
};
|
|
// CASE: second thing middleware does is try to match to a regex
|
|
fakeReq.url.match = function () {
|
|
throw new Error('Should have exited immediately');
|
|
};
|
|
handleImageSizes(fakeReq, {}, function next() {
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('calls next immediately if the url does not match /size/something/', function (done) {
|
|
const fakeReq = {
|
|
url: '/size//'
|
|
};
|
|
// CASE: second thing middleware does is try to match to a regex
|
|
fakeReq.url.match = function () {
|
|
throw new Error('Should have exited immediately');
|
|
};
|
|
handleImageSizes(fakeReq, {}, function next() {
|
|
done();
|
|
});
|
|
});
|
|
});
|