0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/test/unit/web/middleware/image/handle-image-sizes_spec.js
Hannah Wolfe 7f1d3ebc07
Move tests from core to root (#11700)
- move all test files from core/test to test/
- updated all imports and other references
- all code inside of core/ is then application code
- tests are correctly at the root level
- consistent with other repos/projects

Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
2020-03-30 16:26:47 +01:00

44 lines
1.6 KiB
JavaScript

const should = require('should');
const handleImageSizes = require('../../../../../core/server/web/shared/middlewares/image/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();
});
});
});