Produced by Araxis Merge on 10/4/2017 8:04:36 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | rdk.zip\rdk\product\production\rdk\src\write\notes | notes-validator-spec.js | Mon Aug 21 12:51:00 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\write\notes | notes-validator-spec.js | Tue Oct 3 18:54:49 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 18 | 818 |
| Changed | 17 | 44 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 'use stric t'; | |
| 2 | ||
| 3 | var _ = re quire('lod ash'); | |
| 4 | var notesV alidator = require(' ./notes-va lidator'); | |
| 5 | var writeb ackContext ; | |
| 6 | ||
| 7 | describe(' The Notes input vali dator', fu nction() { | |
| 8 | before Each(funct ion() { | |
| 9 | wr itebackCon text = { | |
| 10 | resource Id: '12345 ', | |
| 11 | duz: { | |
| 12 | ' R E D A CTED ': 'duz1', | |
| 13 | ' RED A CTED ': 'duz2' | |
| 14 | }, | |
| 15 | vistaCon fig: { | |
| 16 | host: ' IP ', | |
| 17 | port: PORT , | |
| 18 | accessCode : ' REDACT ', | |
| 19 | verifyCode : ' REDACTED ', | |
| 20 | localIP: ' IP ', | |
| 21 | loca lAddress: 'localhost ', | |
| 22 | cont ext: 'HMP UI CONTEXT ' | |
| 23 | }, | |
| 24 | appConfi g: { | |
| 25 | jdss erver: {} | |
| 26 | }, | |
| 27 | model: { | |
| 28 | 'aut horUid': ' 1000000025 5', | |
| 29 | 'documentD efUid': 'u rn:va:doc- def: R E D A CTED :40', | |
| 30 | 'enc ounterDate Time': '19 9310131400 ', | |
| 31 | 'enc ounterCate goryName': 'Appointm ent', | |
| 32 | 'ref erenceDate Time': '20 1507101410 ', | |
| 33 | 'locationU id': 'urn: va:locatio n: R E D A CTED :w9', | |
| 34 | 'pat ientIcn': '10110V004 877', | |
| 35 | 'pid': ' R E D A CTED ;8', | |
| 36 | 'sta tus': 'UNS IGNED' | |
| 37 | }, | |
| 38 | intercep torResults : { | |
| 39 | pati entIdentif iers: { | |
| 40 | 'siteDfn': ' R E D A CTED ;8', | |
| 41 | 'dfn': '8' , | |
| 42 | 'site': ' R E D A CTED ' | |
| 43 | } | |
| 44 | }, | |
| 45 | logger: sinon.stub (require(' bunyan').c reateLogge r({ | |
| 46 | name : 'notes-v alidator' | |
| 47 | })) | |
| 48 | }; | |
| 49 | }); | |
| 50 | ||
| 51 | descri be('valida tes delete function' , function () { | |
| 52 | it ('adds uid to the wr itebackCon text.model ', functio n(done) { | |
| 53 | notesVal idator.del ete(writeb ackContext , function () { | |
| 54 | expe ct(writeba ckContext. model.uid) .to.eql('1 2345'); | |
| 55 | done (); | |
| 56 | }); | |
| 57 | }) ; | |
| 58 | }); | |
| 59 | ||
| 60 | descri be('valida tes sign f unction', function() { | |
| 61 | it ('returns an error i f the sign ature code does not exisit', f unction(do ne) { | |
| 62 | notesVal idator.sig n(writebac kContext, function(e rror) { | |
| 63 | expe ct(error). to.eql('si gnatureCod e is missi ng from th e model. A signature code is r equired to sign a no te.'); | |
| 64 | done (); | |
| 65 | }); | |
| 66 | }) ; | |
| 67 | ||
| 68 | it ('encrypts the signa ture code and sets t he dfn', f unction(do ne) { | |
| 69 | writebackC ontext.mod el.signatu reCode = ' REDACTED '; | |
| 70 | writebac kContext.m odel.signI tems = [{} ]; | |
| 71 | notesVal idator.sig n(writebac kContext, function() { | |
| 72 | expe ct(writeba ckContext. model.sign atureCode) .to.be.tru thy(); | |
| 73 | expe ct(writeba ckContext. model.dfn) .to.eql('8 '); | |
| 74 | done (); | |
| 75 | }); | |
| 76 | }) ; | |
| 77 | }); | |
| 78 | ||
| 79 | descri be('valida tes update function' , function () { | |
| 80 | it ('returns an error i f the pid does not e xisit', fu nction(don e) { | |
| 81 | delete w ritebackCo ntext.inte rceptorRes ults.patie ntIdentifi ers.siteDf n; | |
| 82 | notesVal idator.upd ate(writeb ackContext , function (error) { | |
| 83 | expe ct(error). to.eql('Th e note\'s IEN and pa tient\'s P ID are nee ded to upd ate a note .'); | |
| 84 | done (); | |
| 85 | }); | |
| 86 | }) ; | |
| 87 | ||
| 88 | it ('returns an error i f the ien does not e xisit', fu nction(don e) { | |
| 89 | delete w ritebackCo ntext.reso urceId; | |
| 90 | notesVal idator.upd ate(writeb ackContext , function (error) { | |
| 91 | expe ct(error). to.eql('Th e note\'s IEN and pa tient\'s P ID are nee ded to upd ate a note .'); | |
| 92 | done (); | |
| 93 | }); | |
| 94 | }) ; | |
| 95 | ||
| 96 | it ('sets the pid, site Hash, auth orUid, uid , and loca lId in the writeback Context.mo del where siteHash i s undefine d', functi on(done) { | |
| 97 | delete w ritebackCo ntext.inte rceptorRes ults.patie ntIdentifi ers.site; | |
| 98 | notesVal idator.upd ate(writeb ackContext , function () { | |
| 99 | expe ct(writeba ckContext. model.pid) .to.eql('8 '); | |
| 100 | expe ct(writeba ckContext. model.site Hash).to.b e.falsy(); | |
| 101 | expe ct(writeba ckContext. model.uid) .to.eql('1 2345'); | |
| 102 | expe ct(writeba ckContext. model.loca lId).to.eq l('12345') ; | |
| 103 | done (); | |
| 104 | }); | |
| 105 | }) ; | |
| 106 | ||
| 107 | it ('sets the pid, site Hash, auth orUid, uid , and loca lId in the writeback Context.mo del where siteHash i s defined' , function (done) { | |
| 108 | writebackC ontext.int erceptorRe sults.pati entIdentif iers.site = ' R E D A CTED '; | |
| 109 | notesVal idator.upd ate(writeb ackContext , function () { | |
| 110 | expe ct(writeba ckContext. model.pid) .to.eql('8 '); | |
| 111 | expect(wri tebackCont ext.model. siteHash). to.eql(' R E D A CTED '); | |
| 112 | expe ct(writeba ckContext. model.uid) .to.eql('1 2345'); | |
| 113 | expe ct(writeba ckContext. model.loca lId).to.eq l('12345') ; | |
| 114 | done (); | |
| 115 | }); | |
| 116 | }) ; | |
| 117 | }); | |
| 118 | ||
| 119 | descri be('valida tes unsign ed functio n', functi on() { | |
| 120 | it ('returns an error i f the titl eId (docum entDefUid) does not exisit', f unction(do ne) { | |
| 121 | delete w ritebackCo ntext.mode l.document DefUid; | |
| 122 | notesVal idator.uns igned(writ ebackConte xt, functi on(error) { | |
| 123 | expe ct(error). to.eql('do cumentDefU id is miss ing from t he model. A title is needed to save a no te.'); | |
| 124 | done (); | |
| 125 | }); | |
| 126 | }) ; | |
| 127 | ||
| 128 | // it('calls httpUtil. get with e rror', fun ction(done ) { | |
| 129 | // writebackC ontext.sit eHash = ' R E D A CTED '; | |
| 130 | ||
| 131 | // sinon .stub(http Util, 'get ', functio n(options, callback) { | |
| 132 | // v ar err = ' error'; | |
| 133 | // v ar fakeRes ponse = {s tatusCode: 200}; | |
| 134 | // v ar fakeBod y = {data: {currentI temCount: 0, items: []}}; | |
| 135 | // r eturn call back(err, fakeRespon se, fakeBo dy); | |
| 136 | // }); | |
| 137 | ||
| 138 | // notes Validator. unsigned(w ritebackCo ntext, fun ction(erro r) { | |
| 139 | // e xpect(erro r).to.be.t ruthy(); | |
| 140 | // d one(); | |
| 141 | // }); | |
| 142 | // }); | |
| 143 | ||
| 144 | // it('calls httpUtil. get withou t error us ing existi ng Visit', function( done) { | |
| 145 | // writebackC ontext.sit eHash = ' R E D A CTED '; | |
| 146 | ||
| 147 | // sinon .stub(http Util, 'get ', functio n(options, callback) { | |
| 148 | // v ar err = n ull; | |
| 149 | // v ar fakeRes ponse = {s tatusCode: 200}; | |
| 150 | // v ar fakeBod y = { | |
| 151 | // data: { | |
| 152 | // cur rentItemCo unt: 3, | |
| 153 | // ite ms: [] | |
| 154 | // } | |
| 155 | // } ; | |
| 156 | // r eturn call back(err, fakeRespon se, fakeBo dy); | |
| 157 | // }); | |
| 158 | ||
| 159 | // notes Validator. unsigned(w ritebackCo ntext, fun ction(erro r, result) { | |
| 160 | // e xpect(erro r).to.be.f alsy(); | |
| 161 | // d one(); | |
| 162 | // }); | |
| 163 | // }); | |
| 164 | ||
| 165 | // it('calls httpUtil. get withou t error us ing new Vi sit', func tion(done) { | |
| 166 | // writebackC ontext.sit eHash = ' R E D A CTED '; | |
| 167 | // delet e writebac kContext.m odel.encou nterCatego ryName; | |
| 168 | // write backContex t.model.en counterSer viceCatego ry = 'A'; | |
| 169 | ||
| 170 | // sinon .stub(http Util, 'get ', functio n(options, callback) { | |
| 171 | // v ar err = n ull; | |
| 172 | // v ar fakeRes ponse = {s tatusCode: 200}; | |
| 173 | // v ar fakeBod y = { | |
| 174 | // data: { | |
| 175 | // cur rentItemCo unt: 3, | |
| 176 | // ite ms: [] | |
| 177 | // } | |
| 178 | // } ; | |
| 179 | // r eturn call back(err, fakeRespon se, fakeBo dy); | |
| 180 | // }); | |
| 181 | ||
| 182 | // notes Validator. unsigned(w ritebackCo ntext, fun ction(erro r, result) { | |
| 183 | // e xpect(erro r).to.be.f alsy(); | |
| 184 | // d one(); | |
| 185 | // }); | |
| 186 | // }); | |
| 187 | ||
| 188 | // it('calls validateV isitExist with error using new Visit whe re service Category i s missing' , function (done) { | |
| 189 | // writebackC ontext.sit eHash = ' R E D A CTED '; | |
| 190 | // delet e writebac kContext.m odel.encou nterCatego ryName; | |
| 191 | ||
| 192 | // notes Validator. unsigned(w ritebackCo ntext, fun ction(erro r, result) { | |
| 193 | // e xpect(erro r).to.eql( 'The servi ce categor y is not d efined in the associ ated encou nter conte xt. Please check tha t the enco unter cont ext is cor rect.'); | |
| 194 | // d one(); | |
| 195 | // }); | |
| 196 | // }); | |
| 197 | ||
| 198 | // it('calls validateV isitExist with error using new Visit whe re encount erDateTime is missin g', functi on(done) { | |
| 199 | // writebackC ontext.sit eHash = ' R E D A CTED '; | |
| 200 | // delet e writebac kContext.m odel.encou nterCatego ryName; | |
| 201 | // delet e writebac kContext.m odel.encou nterDateTi me; | |
| 202 | // write backContex t.model.en counterSer viceCatego ry = 'A'; | |
| 203 | ||
| 204 | // notes Validator. unsigned(w ritebackCo ntext, fun ction(erro r, result) { | |
| 205 | // e xpect(erro r).to.eql( 'The encou nter date/ time is no t defined in the ass ociated en counter co ntext. Ple ase check that the e ncounter c ontext is correct.') ; | |
| 206 | // d one(); | |
| 207 | // }); | |
| 208 | // }); | |
| 209 | ||
| 210 | // it('calls validateV isitExist with error using new Visit whe re locatio nUid is mi ssing', fu nction(don e) { | |
| 211 | // writebackC ontext.sit eHash = ' R E D A CTED '; | |
| 212 | // delet e writebac kContext.m odel.encou nterCatego ryName; | |
| 213 | // delet e writebac kContext.m odel.locat ionUid; | |
| 214 | // write backContex t.model.en counterSer viceCatego ry = 'A'; | |
| 215 | ||
| 216 | // notes Validator. unsigned(w ritebackCo ntext, fun ction(erro r, result) { | |
| 217 | // e xpect(erro r).to.eql( 'The encou nter locat ion ID is not define d in the a ssociated encounter context. P lease chec k that the encounter context i s correct. '); | |
| 218 | // d one(); | |
| 219 | // }); | |
| 220 | // }); | |
| 221 | ||
| 222 | // it('calls httpUtil. get with e ncounter m issing err or', funct ion(done) { | |
| 223 | // writebackC ontext.sit eHash = ' R E D A CTED '; | |
| 224 | ||
| 225 | // sinon .stub(http Util, 'get ', functio n(options, callback) { | |
| 226 | // v ar err = n ull; | |
| 227 | // v ar fakeRes ponse = {s tatusCode: 200}; | |
| 228 | // v ar fakeBod y = { | |
| 229 | // data: { | |
| 230 | // cur rentItemCo unt: -1, | |
| 231 | // ite ms: [] | |
| 232 | // } | |
| 233 | // } ; | |
| 234 | // r eturn call back(err, fakeRespon se, fakeBo dy); | |
| 235 | // }); | |
| 236 | ||
| 237 | // notes Validator. unsigned(w ritebackCo ntext, fun ction(erro r, result) { | |
| 238 | // e xpect(erro r).to.eql( 'The encou nter that is associa ted with t he note ca nnot be fo und.'); | |
| 239 | // d one(); | |
| 240 | // }); | |
| 241 | // }); | |
| 242 | }); | |
| 243 | ||
| 244 | descri be('checkI fCosignReq uired', fu nction() { | |
| 245 | va r rpcClien tFactory = require(' ../core/rp c-client-f actory'); | |
| 246 | it ('reads si gnItems fr om model.s ignItems[] .documentD efUid', fu nction(don e) { | |
| 247 | var writ ebackConte xt = {}; | |
| 248 | _.set(wr itebackCon text, 'mod el.signIte ms[0].docu mentDefUid ', 'urn:va :item0'); | |
| 249 | _.set(wr itebackCon text, 'mod el.signIte ms[1].docu mentDefUid ', 'urn:va :item1'); | |
| 250 | _.set(wr itebackCon text, 'sit eHash', 'A BCD'); | |
| 251 | _.set(wr itebackCon text, 'duz .ABCD', 'u serDfn'); | |
| 252 | var rpcC lient = {} ; | |
| 253 | var exec uteErr = n ull; | |
| 254 | var exec uteRespons e = null; | |
| 255 | rpcClien t.execute = sinon.st ub(); | |
| 256 | rpcClien t.execute. callsArgWi th(2, exec uteErr, ex ecuteRespo nse); | |
| 257 | sinon.st ub(rpcClie ntFactory, 'getRpcCl ient', fun ction(writ ebackConte xt, vistaC ontext, ca llback) { | |
| 258 | var err = null ; | |
| 259 | retu rn callbac k(err, rpc Client); | |
| 260 | }); | |
| 261 | var rpcN ame = 'TIU REQUIRES COSIGNATUR E'; | |
| 262 | notesVal idator.che ckIfCosign Required(w ritebackCo ntext, fun ction(err) { | |
| 263 | expe ct(err).to .be.falsy( ); | |
| 264 | expe ct(rpcClie nt.execute .calledWit h( | |
| 265 | rpcName, [ 'item0', ' ', 'userDf n', sinon. match.stri ng], | |
| 266 | sinon.matc h.func | |
| 267 | )).t o.be.true( ); | |
| 268 | expe ct(rpcClie nt.execute .calledWit h( | |
| 269 | rpcName, [ 'item1', ' ', 'userDf n', sinon. match.stri ng], | |
| 270 | sinon.matc h.func | |
| 271 | )).t o.be.true( ); | |
| 272 | expe ct(rpcClie nt.execute .calledTwi ce).to.be. true(); | |
| 273 | done (); | |
| 274 | }); | |
| 275 | }) ; | |
| 276 | it ('reads si gnItems fr om model.s ignedAdden dums[].doc umentDefUi d', functi on(done) { | |
| 277 | var writ ebackConte xt = {}; | |
| 278 | _.set(wr itebackCon text, 'mod el.signedA ddendums[0 ].document DefUid', ' urn:va:ite m0'); | |
| 279 | _.set(wr itebackCon text, 'mod el.signedA ddendums[1 ].document DefUid', ' urn:va:ite m1'); | |
| 280 | _.set(wr itebackCon text, 'sit eHash', 'A BCD'); | |
| 281 | _.set(wr itebackCon text, 'duz .ABCD', 'u serDfn'); | |
| 282 | var rpcC lient = {} ; | |
| 283 | var exec uteErr = n ull; | |
| 284 | var exec uteRespons e = null; | |
| 285 | rpcClien t.execute = sinon.st ub(); | |
| 286 | rpcClien t.execute. callsArgWi th(2, exec uteErr, ex ecuteRespo nse); | |
| 287 | sinon.st ub(rpcClie ntFactory, 'getRpcCl ient', fun ction(writ ebackConte xt, vistaC ontext, ca llback) { | |
| 288 | var err = null ; | |
| 289 | retu rn callbac k(err, rpc Client); | |
| 290 | }); | |
| 291 | var rpcN ame = 'TIU REQUIRES COSIGNATUR E'; | |
| 292 | notesVal idator.che ckIfCosign Required(w ritebackCo ntext, fun ction(err) { | |
| 293 | expe ct(err).to .be.falsy( ); | |
| 294 | expe ct(rpcClie nt.execute .calledWit h( | |
| 295 | rpcName, [ 'item0', ' ', 'userDf n', sinon. match.stri ng], | |
| 296 | sinon.matc h.func | |
| 297 | )).t o.be.true( ); | |
| 298 | expe ct(rpcClie nt.execute .calledWit h( | |
| 299 | rpcName, [ 'item1', ' ', 'userDf n', sinon. match.stri ng], | |
| 300 | sinon.matc h.func | |
| 301 | )).t o.be.true( ); | |
| 302 | expe ct(rpcClie nt.execute .calledTwi ce).to.be. true(); | |
| 303 | done (); | |
| 304 | }); | |
| 305 | }) ; | |
| 306 | it ('reads re fIds from model.docu mentDefUid ', functio n(done) { | |
| 307 | var writ ebackConte xt = {}; | |
| 308 | _.set(wr itebackCon text, 'mod el.documen tDefUid', 'urn:va:it em0'); | |
| 309 | _.set(wr itebackCon text, 'sit eHash', 'A BCD'); | |
| 310 | _.set(wr itebackCon text, 'duz .ABCD', 'u serDfn'); | |
| 311 | var rpcC lient = {} ; | |
| 312 | var exec uteErr = n ull; | |
| 313 | var exec uteRespons e = null; | |
| 314 | rpcClien t.execute = sinon.st ub(); | |
| 315 | rpcClien t.execute. callsArgWi th(2, exec uteErr, ex ecuteRespo nse); | |
| 316 | sinon.st ub(rpcClie ntFactory, 'getRpcCl ient', fun ction(writ ebackConte xt, vistaC ontext, ca llback) { | |
| 317 | var err = null ; | |
| 318 | retu rn callbac k(err, rpc Client); | |
| 319 | }); | |
| 320 | var rpcN ame = 'TIU REQUIRES COSIGNATUR E'; | |
| 321 | notesVal idator.che ckIfCosign Required(w ritebackCo ntext, fun ction(err) { | |
| 322 | expe ct(err).to .be.falsy( ); | |
| 323 | expe ct(rpcClie nt.execute .calledWit h( | |
| 324 | rpcName, [ 'item0', ' ', 'userDf n', sinon. match.stri ng], | |
| 325 | sinon.matc h.func | |
| 326 | )).t o.be.true( ); | |
| 327 | expe ct(rpcClie nt.execute .calledOnc e).to.be.t rue(); | |
| 328 | done (); | |
| 329 | }); | |
| 330 | }) ; | |
| 331 | it ('uses a d efault ref Id when th ere are no items', f unction(do ne) { | |
| 332 | var writ ebackConte xt = {}; | |
| 333 | _.set(wr itebackCon text, 'mod el.signIte ms', []); | |
| 334 | _.set(wr itebackCon text, 'sit eHash', 'A BCD'); | |
| 335 | _.set(wr itebackCon text, 'duz .ABCD', 'u serDfn'); | |
| 336 | var rpcC lient = {} ; | |
| 337 | var exec uteErr = n ull; | |
| 338 | var exec uteRespons e = null; | |
| 339 | rpcClien t.execute = sinon.st ub(); | |
| 340 | rpcClien t.execute. callsArgWi th(2, exec uteErr, ex ecuteRespo nse); | |
| 341 | sinon.st ub(rpcClie ntFactory, 'getRpcCl ient', fun ction(writ ebackConte xt, vistaC ontext, ca llback) { | |
| 342 | var err = null ; | |
| 343 | retu rn callbac k(err, rpc Client); | |
| 344 | }); | |
| 345 | var rpcN ame = 'TIU REQUIRES COSIGNATUR E'; | |
| 346 | notesVal idator.che ckIfCosign Required(w ritebackCo ntext, fun ction(err) { | |
| 347 | expe ct(err).to .be.falsy( ); | |
| 348 | expe ct(rpcClie nt.execute .calledWit h( | |
| 349 | rpcName, [ '0', '', ' userDfn', sinon.matc h.string], | |
| 350 | sinon.matc h.func | |
| 351 | )).t o.be.true( ); | |
| 352 | expe ct(rpcClie nt.execute .calledOnc e).to.be.t rue(); | |
| 353 | done (); | |
| 354 | }); | |
| 355 | }) ; | |
| 356 | it ('returns an error w hen it can not get a n RPC clie nt', funct ion(done) { | |
| 357 | var writ ebackConte xt = {}; | |
| 358 | _.set(wr itebackCon text, 'mod el.signIte ms[0].docu mentDefUid ', 'urn:va :item0'); | |
| 359 | _.set(wr itebackCon text, 'mod el.signIte ms[1].docu mentDefUid ', 'urn:va :item1'); | |
| 360 | var rpcC lient = nu ll; | |
| 361 | sinon.st ub(rpcClie ntFactory, 'getRpcCl ient', fun ction(writ ebackConte xt, vistaC ontext, ca llback) { | |
| 362 | var err = new Error('can not get R PC client' ); | |
| 363 | retu rn callbac k(err, rpc Client); | |
| 364 | }); | |
| 365 | notesVal idator.che ckIfCosign Required(w ritebackCo ntext, fun ction(err) { | |
| 366 | expe ct(err).to .match(/Th is note ti tle requir es that a cosigner/) ; | |
| 367 | done (); | |
| 368 | }); | |
| 369 | }) ; | |
| 370 | it ('returns the expect ed error r esponse wh en an RPC returns an error', f unction(do ne) { | |
| 371 | var writ ebackConte xt = {}; | |
| 372 | _.set(wr itebackCon text, 'mod el.signIte ms[0].docu mentDefUid ', 'urn:va :item0'); | |
| 373 | _.set(wr itebackCon text, 'mod el.signIte ms[1].docu mentDefUid ', 'urn:va :item1'); | |
| 374 | _.set(wr itebackCon text, 'sit eHash', 'A BCD'); | |
| 375 | _.set(wr itebackCon text, 'duz .ABCD', 'u serDfn'); | |
| 376 | var rpcC lient = {} ; | |
| 377 | var exec uteErr = n ull; | |
| 378 | var exec uteRespons e = '1'; | |
| 379 | rpcClien t.execute = sinon.st ub(); | |
| 380 | rpcClien t.execute. callsArgWi th(2, exec uteErr, ex ecuteRespo nse); | |
| 381 | sinon.st ub(rpcClie ntFactory, 'getRpcCl ient', fun ction(writ ebackConte xt, vistaC ontext, ca llback) { | |
| 382 | var err = null ; | |
| 383 | retu rn callbac k(err, rpc Client); | |
| 384 | }); | |
| 385 | var rpcN ame = 'TIU REQUIRES COSIGNATUR E'; | |
| 386 | notesVal idator.che ckIfCosign Required(w ritebackCo ntext, fun ction(err) { | |
| 387 | expe ct(err).to .match(/Th is note ti tle requir es that a cosigner/) ; | |
| 388 | expe ct(rpcClie nt.execute .calledWit h( | |
| 389 | rpcName, [ 'item0', ' ', 'userDf n', sinon. match.stri ng], | |
| 390 | sinon.matc h.func | |
| 391 | )).t o.be.true( ); | |
| 392 | expe ct(rpcClie nt.execute .calledWit h( | |
| 393 | rpcName, [ 'item1', ' ', 'userDf n', sinon. match.stri ng], | |
| 394 | sinon.matc h.func | |
| 395 | )).t o.be.true( ); | |
| 396 | expe ct(rpcClie nt.execute .calledTwi ce).to.be. true(); | |
| 397 | done (); | |
| 398 | }); | |
| 399 | }) ; | |
| 400 | it ('returns the expect ed error r esponse wh en the RPC says a co signer is required', function( done) { | |
| 401 | var writ ebackConte xt = {}; | |
| 402 | _.set(wr itebackCon text, 'mod el.signIte ms[0].docu mentDefUid ', 'urn:va :item0'); | |
| 403 | _.set(wr itebackCon text, 'mod el.signIte ms[1].docu mentDefUid ', 'urn:va :item1'); | |
| 404 | _.set(wr itebackCon text, 'sit eHash', 'A BCD'); | |
| 405 | _.set(wr itebackCon text, 'duz .ABCD', 'u serDfn'); | |
| 406 | var rpcC lient = {} ; | |
| 407 | var exec uteErr = n ew Error(' error exec uting RPC' ); | |
| 408 | var exec uteRespons e = null; | |
| 409 | rpcClien t.execute = sinon.st ub(); | |
| 410 | rpcClien t.execute. callsArgWi th(2, exec uteErr, ex ecuteRespo nse); | |
| 411 | sinon.st ub(rpcClie ntFactory, 'getRpcCl ient', fun ction(writ ebackConte xt, vistaC ontext, ca llback) { | |
| 412 | var err = null ; | |
| 413 | retu rn callbac k(err, rpc Client); | |
| 414 | }); | |
| 415 | var rpcN ame = 'TIU REQUIRES COSIGNATUR E'; | |
| 416 | notesVal idator.che ckIfCosign Required(w ritebackCo ntext, fun ction(err) { | |
| 417 | expe ct(err).to .match(/Th is note ti tle requir es that a cosigner/) ; | |
| 418 | expe ct(rpcClie nt.execute .calledWit h( | |
| 419 | rpcName, [ 'item0', ' ', 'userDf n', sinon. match.stri ng], | |
| 420 | sinon.matc h.func | |
| 421 | )).t o.be.true( ); | |
| 422 | expe ct(rpcClie nt.execute .calledWit h( | |
| 423 | rpcName, [ 'item1', ' ', 'userDf n', sinon. match.stri ng], | |
| 424 | sinon.matc h.func | |
| 425 | )).t o.be.true( ); | |
| 426 | expe ct(rpcClie nt.execute .calledTwi ce).to.be. true(); | |
| 427 | done (); | |
| 428 | }); | |
| 429 | }) ; | |
| 430 | }); | |
| 431 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.