1 | "use strict";
|
2 |
|
3 | const assert = require('assert');
|
4 | const failure = require('./failure');
|
5 |
|
6 | describe('failure', function ()
|
7 | {
|
8 | let instance;
|
9 | beforeEach(async function ()
|
10 | {
|
11 | instance = failure({});
|
12 | });
|
13 |
|
14 | it(`should not restrict if settings are not present 1`, function (done)
|
15 | {
|
16 | failure()(null, null, done)
|
17 | });
|
18 |
|
19 | it(`operation`, function ()
|
20 | {
|
21 | let allows = 0;
|
22 | let error = false;
|
23 | while (!error)
|
24 | {
|
25 |
|
26 | let on
|
27 | let req = {};
|
28 | let res = {
|
29 | on: (_, cb) =>
|
30 | {
|
31 | on = cb;
|
32 | },
|
33 | error: () =>
|
34 | {
|
35 | error = true
|
36 | }
|
37 | };
|
38 |
|
39 | instance(req, res, () =>
|
40 | {
|
41 | allows++;
|
42 | res.status = 400;
|
43 | on();
|
44 | });
|
45 | }
|
46 | assert.equal(allows, 5);
|
47 | });
|
48 |
|
49 | })
|