Ghost/test/unit/web/shared/middleware/brute_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

31 lines
1.0 KiB
JavaScript

const should = require('should');
const sinon = require('sinon');
const brute = require('../../../../../core/server/web/shared/middlewares/brute');
describe('brute middleware', function () {
after(function () {
sinon.restore();
});
it('exports a contentApiKey method', function () {
should.equal(typeof brute.contentApiKey, 'function');
});
describe('contentApiKey', function () {
it('calls the contentApiKey method of spam prevention', function () {
const spamPrevention = require('../../../../../core/server/web/shared/middlewares/api/spam-prevention');
const contentApiKeyStub = sinon.stub(spamPrevention, 'contentApiKey');
// CASE: we don't care about what params it takes
// just whether it calls the spam prevention stuff
try {
brute.contentApiKey();
} catch (err) {
// I don't care
} finally {
should.equal(contentApiKeyStub.called, true);
}
});
});
});