File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments