Skip to content

Commit b7e18fd

Browse files
add tests for external accounts validator middleware (#1205)
1 parent 413e593 commit b7e18fd

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const Sinon = require("sinon");
2+
const { externalAccountData } = require("../../../middlewares/validators/external-accounts");
3+
const { expect } = require("chai");
4+
5+
describe("Middleware | Validators | external accounts", function () {
6+
describe("externalAccountsData", function () {
7+
it("allows the request to pass to next function", async function () {
8+
const req = {
9+
body: {
10+
type: "some type",
11+
token: "some token",
12+
attributes: {},
13+
},
14+
};
15+
const res = {};
16+
const nextSpy = Sinon.spy();
17+
await externalAccountData(req, res, nextSpy);
18+
expect(nextSpy.calledOnce).to.be.equal(true);
19+
});
20+
21+
it("stops the propogation of request to the next function", async function () {
22+
const req = {
23+
body: {},
24+
};
25+
const res = {
26+
boom: {
27+
badRequest: () => {},
28+
},
29+
};
30+
const nextSpy = Sinon.spy();
31+
await externalAccountData(req, res, nextSpy).catch((err) => {
32+
expect(err).to.be.an.instanceOf(Error);
33+
});
34+
expect(nextSpy.callCount).to.be.equal(0);
35+
});
36+
});
37+
});

0 commit comments

Comments
 (0)