/
brute_spec.js
27 lines (24 loc) · 1.02 KB
/
brute_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const should = require('should');
const sinon = require('sinon');
const brute = require('../../../../../server/web/shared/middlewares/brute');
describe('brute middleware', function () {
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('../../../../../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);
contentApiKeyStub.reset();
}
});
});
});