Produced by Araxis Merge on 12/7/2018 11:36:03 AM Central Standard 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 | C:\SCRUB\MHED\MHED\VAR 4.10.0\var-web-release-4.10@e10f18de1ef\veteran-appointment-requests\app\modules\new-appointment-request\tests\common\views | facility-layout-spec.js | Mon Oct 22 23:25:20 2018 UTC |
| 2 | C:\MHED-scrubbed\MHED\MHED\VAR 4.10.0\var-web-release-4.10@e10f18de1ef\veteran-appointment-requests\app\modules\new-appointment-request\tests\common\views | facility-layout-spec.js | Fri Dec 7 13:07:34 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 7 | 1076 |
| Changed | 6 | 14 |
| Inserted | 1 | 1 |
| 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 | define([ | |||||
| 2 | 'under score', | |||||
| 3 | 'backb one', | |||||
| 4 | 'modul es/new-app ointment-r equest/res ources/com mon/model' , | |||||
| 5 | 'modul es/new-app ointment-r equest/res ources/com mon/facili ty/model', | |||||
| 6 | 'modul es/new-app ointment-r equest/vie ws/common/ facility/l ayout-view ', | |||||
| 7 | 'modul es/new-app ointment-r equest/vie ws/common/ facility/s ection-vie w', | |||||
| 8 | 'modul es/new-app ointment-r equest/tes ts/helpers /facility- helper', | |||||
| 9 | 'modul es/new-app ointment-r equest/res ources/dir ect/clinic s/collecti on', | |||||
| 10 | 'modul es/new-app ointment-r equest/res ources/com mon/pac-te am/collect ion', | |||||
| 11 | ], functio n(_, Backb one, BaseM odel, Faci lityModel, View, Sec tionView, helpers, C linicsColl ection, Pa cTeamColle ction) { | |||||
| 12 | 'use s trict'; | |||||
| 13 | ||||||
| 14 | ||||||
| 15 | descri be('Schedu ling Facil ity Layout View', fu nction() { | |||||
| 16 | ||||||
| 17 | va r TYPE_OF_ CARE = 'Zo mbie Face Lifts'; | |||||
| 18 | ||||||
| 19 | // Example: WORCESTER CBOC (WORC ESTER, MA) | |||||
| 20 | // Example: any test n ame (ANYNA ME, XX) | |||||
| 21 | // The way t o display a facility | |||||
| 22 | va r REG_EXP = /^[a-zA- Z ]+ \([a- zA-Z]+, [A -Z]{2}\)$/ ; | |||||
| 23 | ||||||
| 24 | ||||||
| 25 | va r view; | |||||
| 26 | va r region; | |||||
| 27 | va r fetch; | |||||
| 28 | va r model; | |||||
| 29 | ||||||
| 30 | va r prepareC linicsColl ection = f unction(la youtView) { | |||||
| 31 | var clin icsCallbac k = new $. Deferred() ; | |||||
| 32 | clinicsC allback.re solve([]); | |||||
| 33 | layoutVi ew.clinics Collection = new Cli nicsCollec tion(); | |||||
| 34 | spyOn(la youtView.c linicsColl ection, 'f etchAllCli nics').and .returnVal ue(clinics Callback); | |||||
| 35 | layoutVi ew.model.s et('unfilt eredClinic s', []); | |||||
| 36 | }; | |||||
| 37 | ||||||
| 38 | va r createMo del = func tion() { | |||||
| 39 | var retv al; | |||||
| 40 | var pacT eamMock = new PacTea mCollectio n(); | |||||
| 41 | var f DNS el = new B ackbone.Co llection() ; | |||||
| 42 | f DNS el.set('fa cilityCode ', 123); | |||||
| 43 | spyOn(pa cTeamMock, 'hasPacTe amAtFacili ty').and.r eturnValue (false); | |||||
| 44 | retval = new BaseM odel({ | |||||
| 45 | type OfCare: ne w Backbone .Model({ | |||||
| 46 | id: 'CR1', | |||||
| 47 | name: 'wha tever', | |||||
| 48 | }), | |||||
| 49 | pacT eam: pacTe amMock, | |||||
| 50 | city State: new Backbone. Model(), | |||||
| 51 | f DNS el: f DNS el, | |||||
| 52 | }); | |||||
| 53 | ||||||
| 54 | return r etval; | |||||
| 55 | }; | |||||
| 56 | ||||||
| 57 | ||||||
| 58 | de scribe('Ba sic testin g and cove rage', fun ction() { | |||||
| 59 | beforeEa ch(functio n() { | |||||
| 60 | fetc h = helper s.collecti onFetchSpy (); | |||||
| 61 | mode l = create Model(); | |||||
| 62 | ||||||
| 63 | spyO n(View.pro totype, 's howRegions ').and.cal lFake(_.no op); | |||||
| 64 | view = new Vie w({model: model}); | |||||
| 65 | prep areClinics Collection (view); | |||||
| 66 | view .collectio n.set(help ers.mockPa tientFacil ity(), {pa rse: true} ); | |||||
| 67 | }); | |||||
| 68 | ||||||
| 69 | it('fetc hes on cre ation', fu nction() { | |||||
| 70 | expe ct(fetch). toHaveBeen Called(); | |||||
| 71 | }); | |||||
| 72 | ||||||
| 73 | it('trig gers show after fetc h', functi on() { | |||||
| 74 | view .collectio n.trigger( 'fetch:suc cess'); | |||||
| 75 | expe ct(view.sh owRegions) .toHaveBee nCalled(); | |||||
| 76 | }); | |||||
| 77 | ||||||
| 78 | it('does not show the sectio n region i f the coll ection is empty', fu nction () { | |||||
| 79 | var section; | |||||
| 80 | ||||||
| 81 | view .collectio n.reset(); | |||||
| 82 | view .showBody( ); | |||||
| 83 | sect ion = view .getRegion s('section '); | |||||
| 84 | ||||||
| 85 | expe ct(section .currentVi ew).toBeUn defined(); | |||||
| 86 | }); | |||||
| 87 | }) ; | |||||
| 88 | ||||||
| 89 | ||||||
| 90 | /* * | |||||
| 91 | * https:// issues.mob ilehealth. DOMAIN . EX /browse/VA R-7864 | |||||
| 92 | * | |||||
| 93 | * As a user | |||||
| 94 | * I want to be able t o select t he specifi c location where I w ant to rec eive care | |||||
| 95 | * So that m y booking process is streamlin ed focuses on a smal ler number of specif ic clinics | |||||
| 96 | * | |||||
| 97 | * When a us er views t he New App ointment/R equest for m, the “ro uting ques tions” sho wn at the top part o f the form | |||||
| 98 | * are revis ed to acco mmodate lo cation lev el booking as follow s: | |||||
| 99 | * / | |||||
| 100 | de scribe('Sp ecificatio n Tests fo r VAR-7865 ', functio n() { | |||||
| 101 | var gas; | |||||
| 102 | ||||||
| 103 | beforeEa ch(functio n() { | |||||
| 104 | regi on = helpe rs.setupTe stingRegio n(); | |||||
| 105 | fetc h = helper s.collecti onFetchSpy (); | |||||
| 106 | mode l = create Model(); | |||||
| 107 | view = new Vie w({ | |||||
| 108 | model: mod el, | |||||
| 109 | typeOfCare Name: TYPE _OF_CARE, | |||||
| 110 | googleAnal yticsProvi der: { | |||||
| 111 | getIns tance: fun ction() { | |||||
| 112 | ga s = jasmin e.createSp yObj('gas' , ['gas']) ; | |||||
| 113 | re turn gas; | |||||
| 114 | }, | |||||
| 115 | }, | |||||
| 116 | }); | |||||
| 117 | prep areClinics Collection (view); | |||||
| 118 | view .collectio n.set(help ers.mockPa tientFacil ity(), {pa rse: true} ); | |||||
| 119 | regi on.show(vi ew); | |||||
| 120 | }); | |||||
| 121 | ||||||
| 122 | afterEac h(helpers. resetTesti ngRegion); | |||||
| 123 | ||||||
| 124 | /** | |||||
| 125 | * 1. La bel: Step 2: Select Location | |||||
| 126 | */ | |||||
| 127 | describe ('1.0.0 - 1.0.0', fu nction() { | |||||
| 128 | it(' shows the correct la bel', func tion() { | |||||
| 129 | var headin g; | |||||
| 130 | var legend ; | |||||
| 131 | var text; | |||||
| 132 | ||||||
| 133 | view.showR egions(); | |||||
| 134 | heading = view.getRe gion('head ing').curr entView.el ; | |||||
| 135 | legend = _ .first(hea ding.getEl ementsByTa gName('leg end')); | |||||
| 136 | text = leg end.innerT ext; | |||||
| 137 | ||||||
| 138 | expect(tex t).toBe('S tep 3: Loc ation'); | |||||
| 139 | }); | |||||
| 140 | }); | |||||
| 141 | ||||||
| 142 | ||||||
| 143 | /** | |||||
| 144 | * 2. Instructio nal text: The follow ing facili ty locatio ns support schedulin g <Type of care sele cted> | |||||
| 145 | * appointmen ts through this app. If you ca nnot find the locati on you nee d, please visit the | |||||
| 146 | * [VA Facili ty Locator ] to conta ct the fac ility for assistance . | |||||
| 147 | * | |||||
| 148 | * 2.2. Hyp erlink “VA Facility Locator” t o: https:/ /www. DOMAIN . EX /directory /guide/div ision.asp? dnum=1 | |||||
| 149 | */ | |||||
| 150 | describe ('2.0.0 - 2.2.0', fu nction() { | |||||
| 151 | var text; | |||||
| 152 | ||||||
| 153 | befo reEach(fun ction() { | |||||
| 154 | var headin g; | |||||
| 155 | var instru ctions; | |||||
| 156 | ||||||
| 157 | view.showR egions(); | |||||
| 158 | heading = view.getRe gion('head ing').curr entView.el ; | |||||
| 159 | instructio ns = _.fir st(heading .getElemen tsByTagNam e('p')); | |||||
| 160 | text = ins tructions. innerHTML. trim(); | |||||
| 161 | }); | |||||
| 162 | ||||||
| 163 | it(' creates th e basic in structions ', functio n() { | |||||
| 164 | expect(tex t.indexOf( 'The follo wing facil ity locati ons ')).to Be(0); | |||||
| 165 | }); | |||||
| 166 | ||||||
| 167 | it(' includes t he type of care sele cted in th e instruct ions', fun ction() { | |||||
| 168 | expect(tex t.indexOf( TYPE_OF_CA RE)).toBeG reaterThan (-1); | |||||
| 169 | }); | |||||
| 170 | ||||||
| 171 | it(' includes t he help ur l in the i nstruction s', functi on() { | |||||
| 172 | expect(tex t.indexOf( view.HELP_ TEXT)).toB eGreaterTh an(-1); | |||||
| 173 | }); | |||||
| 174 | }); | |||||
| 175 | ||||||
| 176 | ||||||
| 177 | /** | |||||
| 178 | * 3. Label: S elect the location y ou want to visit: | |||||
| 179 | * | |||||
| 180 | * 3.1 Drop dow n list box | |||||
| 181 | * | |||||
| 182 | * 3.2 Values: Default dr op down li st will di splay all locations (including , children /divisions and the | |||||
| 183 | * parent s ite(s) its elf) under the paren t site(s) associated with the user’s aut henticatio n | |||||
| 184 | * credenti als where that type of care ha s been des ignated as supported in the ut ility for direct | |||||
| 185 | * scheduli ng, reques ts, or bot h methods of schedul ing. | |||||
| 186 | * | |||||
| 187 | * 3.2.1 Display format sho uld includ e a “frien dly” name configured in the Ut ility, fol lowed by t he city | |||||
| 188 | * and stat e for that location in parenth esis | |||||
| 189 | * | |||||
| 190 | * 3.2.2 Example: Boston VA MC (Boston , MA) | |||||
| 191 | * | |||||
| 192 | * 3.2.4 . Sort the locations alphabeti cally by S tate, then City, the n Location Name | |||||
| 193 | * | |||||
| 194 | */ | |||||
| 195 | describe ('3.0.0 - 3.2.4', fu nction() { | |||||
| 196 | var el; | |||||
| 197 | ||||||
| 198 | befo reEach(fun ction() { | |||||
| 199 | view.showR egions(); | |||||
| 200 | el = view. getRegion( 'section') .currentVi ew.el; | |||||
| 201 | }); | |||||
| 202 | ||||||
| 203 | it(' shows the correct la bel for th e dropdown ', functio n() { | |||||
| 204 | var label = _.first( el.getElem entsByTagN ame('label ')); | |||||
| 205 | var text = label.inn erText; | |||||
| 206 | ||||||
| 207 | // The * i s because it is a re quired fie ld. | |||||
| 208 | expect(tex t).toBe('* Select th e location you want to visit:' ); | |||||
| 209 | }); | |||||
| 210 | ||||||
| 211 | it(' populates the dropdo wn', funct ion() { | |||||
| 212 | var option s = el.get ElementsBy TagName('o ption'); | |||||
| 213 | ||||||
| 214 | // There a re three i tems in th e collecti on and a p laceholder item that reads 'Se lect' | |||||
| 215 | expect(opt ions.lengt h).toBe(4) ; | |||||
| 216 | }); | |||||
| 217 | ||||||
| 218 | it(' uses the f ormat FRIE NDLY_NAME (CITY, STA TE) for ea ch dropdow n Item', f unction() { | |||||
| 219 | var option s = el.get ElementsBy TagName('o ption'); | |||||
| 220 | var last = _.last(op tions); | |||||
| 221 | var text = last.inne rText.trim (); | |||||
| 222 | ||||||
| 223 | expect(tex t).toMatch (REG_EXP); | |||||
| 224 | }); | |||||
| 225 | ||||||
| 226 | // T ODO this i s going to change to group by city/state then alph abetical | |||||
| 227 | it(' should sho rt the dro pdown alph abetically ', functio n() { | |||||
| 228 | var _optio ns = el.ge tElementsB yTagName(' option'); | |||||
| 229 | var option s = Array. prototype. slice.call (_options) ; | |||||
| 230 | var last; | |||||
| 231 | var isPass ing; | |||||
| 232 | var next; | |||||
| 233 | ||||||
| 234 | options.sh ift(); | |||||
| 235 | ||||||
| 236 | last = opt ions.shift (); | |||||
| 237 | isPassing = true; | |||||
| 238 | ||||||
| 239 | while (opt ions.lengt h) { | |||||
| 240 | next = options.s hift(); | |||||
| 241 | if (ne xt.innerTe xt.localeC ompare(las t.innerTex t) < 1) { | |||||
| 242 | is Passing = false; | |||||
| 243 | br eak; | |||||
| 244 | } | |||||
| 245 | last = next; | |||||
| 246 | } | |||||
| 247 | ||||||
| 248 | expect(isP assing).to BeTruthy() ; | |||||
| 249 | }); | |||||
| 250 | }); | |||||
| 251 | ||||||
| 252 | ||||||
| 253 | /** | |||||
| 254 | * 4. If only on e location is availa ble, selec t that opt ion by def ault and d isplay: | |||||
| 255 | * | |||||
| 256 | * 4.1. Instructio nal text: One locati on support s scheduli ng <insert type of c are> appoi ntments th rough this | |||||
| 257 | * app. | |||||
| 258 | * | |||||
| 259 | * 4.2. Display lo cation nam e (city, s tate) | |||||
| 260 | */ | |||||
| 261 | describe ('4.0.0 - 4.2.0', fu nction() { | |||||
| 262 | var spy; | |||||
| 263 | var dummyRetur nView = ne w Backbone .View(); | |||||
| 264 | var el; | |||||
| 265 | ||||||
| 266 | befo reEach(fun ction() { | |||||
| 267 | view.colle ction.shif t(); | |||||
| 268 | view.colle ction.shif t(); | |||||
| 269 | spy = spyO n(view, 'g etSingleIt emView').a nd.returnV alue(dummy ReturnView ); | |||||
| 270 | view.showR egions(); | |||||
| 271 | el = view. el; | |||||
| 272 | }); | |||||
| 273 | ||||||
| 274 | it(' shows the correct in structions for when there is o nly one ma tching fac ility', fu nction() { | |||||
| 275 | var p = _. first(el.g etElements ByTagName( 'p')); | |||||
| 276 | var text = p.innerTe xt.trim(); | |||||
| 277 | ||||||
| 278 | expect(tex t.indexOf( 'One locat ion suppor ts schedul ing')).toB e(0); | |||||
| 279 | expect(tex t.indexOf( TYPE_OF_CA RE)).toBeG reaterThan (-1); | |||||
| 280 | expect(spy ).toHaveBe enCalled() ; | |||||
| 281 | }); | |||||
| 282 | ||||||
| 283 | // i t('display s the name of the fa cility in the format : NAME (CI TY, STATE) ', functio n() { | |||||
| 284 | // var spa n = _.last (el.getEle mentsByTag Name('span ')); | |||||
| 285 | // var tex t = span.i nnerText.t rim(); | |||||
| 286 | // expect( text).toMa tch(REG_EX P); | |||||
| 287 | // } ); | |||||
| 288 | }); | |||||
| 289 | ||||||
| 290 | ||||||
| 291 | /** | |||||
| 292 | * 5. If no loca tions are found wher e the care is suppor ted, displ ay: | |||||
| 293 | * | |||||
| 294 | * 5.1. Unfortunat ely, there are no lo cations wh ere you ar e register ed that ar e offering primary c are | |||||
| 295 | * through th is app. | |||||
| 296 | */ | |||||
| 297 | describe ('5.0.0 - 5.1.0', fu nction() { | |||||
| 298 | it(' generates the correc t instruct ions where there are no facili ties', fun ction() { | |||||
| 299 | var instru ctions; | |||||
| 300 | var frag; | |||||
| 301 | var anchor s; | |||||
| 302 | var anchor ; | |||||
| 303 | ||||||
| 304 | view.colle ction.rese t(); | |||||
| 305 | instructio ns = view. getInstruc tions(); | |||||
| 306 | frag = doc ument.crea teElement( 'div'); | |||||
| 307 | frag.inner HTML = ins tructions; | |||||
| 308 | anchors = frag.getEl ementsByTa gName('a') ; | |||||
| 309 | anchor = _ .first(anc hors); | |||||
| 310 | ||||||
| 311 | // Shows a n error me ssage and displays a link to a help page . | |||||
| 312 | expect(ins tructions) .toContain ('Unfortun ately'); | |||||
| 313 | expect(anc hor.href). toEqual('h ttps://www . DOMAIN . EX /directory /guide/div ision.asp? dnum=1'); | |||||
| 314 | }); | |||||
| 315 | }); | |||||
| 316 | }) ; | |||||
| 317 | ||||||
| 318 | /* * | |||||
| 319 | * https:// issues.mob ilehealth. DOMAIN . EX /browse/VA R-8702 | |||||
| 320 | * | |||||
| 321 | * Given a u ser has se lected Exp ress Care from the T ype of Car e drop dow n, when th e user | |||||
| 322 | * selects a location (or the de fault loca tion is di splayed), display th e followin g text | |||||
| 323 | * below the location selection question: Express Ca re request at this l ocation mu st be | |||||
| 324 | * submitted before <e nd time> < time zone> . | |||||
| 325 | * / | |||||
| 326 | de scribe('Sp ecificatio n Tests fo r VAR-8702 ', functio n() { | |||||
| 327 | var time ; | |||||
| 328 | var faci lityModel; | |||||
| 329 | var expe ctedText; | |||||
| 330 | ||||||
| 331 | beforeEa ch(functio n() { | |||||
| 332 | time = '13:00 EST'; | |||||
| 333 | faci lityModel = new Faci lityModel( { | |||||
| 334 | expressTim es: { | |||||
| 335 | start: '08:00', | |||||
| 336 | end: ' 13:00', | |||||
| 337 | timezo ne: 'EST', | |||||
| 338 | offset Utc: '-05: 00', | |||||
| 339 | }, | |||||
| 340 | }, { parse: tru e}); | |||||
| 341 | expe ctedText = 'Express Care reque st at this location must be su bmitted be fore ' + t ime + '.'; | |||||
| 342 | }); | |||||
| 343 | ||||||
| 344 | describe ('facility layout vi ew', funct ion() { | |||||
| 345 | it(' generates the correc t express message fo r a single facility' , function () { | |||||
| 346 | var _view = new View ({ | |||||
| 347 | model: new BaseM odel({ | |||||
| 348 | ty peOfCare: new Backbo ne.Model({ | |||||
| 349 | id: 'CR1 ', | |||||
| 350 | name: 'w hatever', | |||||
| 351 | }) , | |||||
| 352 | ci tyState: n ew Backbon e.Model(), | |||||
| 353 | }), | |||||
| 354 | typeOf CareName: TYPE_OF_CA RE, | |||||
| 355 | }); | |||||
| 356 | var output = _view.g etExpressM essage('CR 1', facili tyModel); | |||||
| 357 | prepareCli nicsCollec tion(view) ; | |||||
| 358 | ||||||
| 359 | expect(out put).toBe( expectedTe xt); | |||||
| 360 | }); | |||||
| 361 | }); | |||||
| 362 | ||||||
| 363 | describe ('facility section v iew', func tion() { | |||||
| 364 | var sectionVie w; | |||||
| 365 | var gas; | |||||
| 366 | ||||||
| 367 | befo reEach(fun ction() { | |||||
| 368 | var sectio nRegion; | |||||
| 369 | ||||||
| 370 | region = h elpers.set upTestingR egion(); | |||||
| 371 | fetch = he lpers.coll ectionFetc hSpy(); | |||||
| 372 | model = cr eateModel( ); | |||||
| 373 | view = new View({ | |||||
| 374 | model: model, | |||||
| 375 | typeOf CareName: TYPE_OF_CA RE, | |||||
| 376 | google AnalyticsP rovider: { | |||||
| 377 | ge tInstance: function( ) { | |||||
| 378 | gas = ja smine.crea teSpyObj(' gas', ['ga s']); | |||||
| 379 | return g as; | |||||
| 380 | }, | |||||
| 381 | }, | |||||
| 382 | }); | |||||
| 383 | prepareCli nicsCollec tion(view) ; | |||||
| 384 | view.colle ction.set( helpers.mo ckPatientF acility(), {parse: t rue}); | |||||
| 385 | region.sho w(view); | |||||
| 386 | view.showR egions(); | |||||
| 387 | ||||||
| 388 | sectionReg ion = view .getRegion ('section' ); | |||||
| 389 | sectionVie w = sectio nRegion.cu rrentView; | |||||
| 390 | }); | |||||
| 391 | ||||||
| 392 | afte rEach(help ers.resetT estingRegi on); | |||||
| 393 | ||||||
| 394 | it(' appends th e dom with the expre ss message after fac ility is s elected', function() { | |||||
| 395 | var output ; | |||||
| 396 | ||||||
| 397 | sectionVie w._insertE xpressCare Message(fa cilityMode l); | |||||
| 398 | output = s ectionView .ui.expres s.text(); | |||||
| 399 | ||||||
| 400 | expect(out put).toBe( expectedTe xt); | |||||
| 401 | }); | |||||
| 402 | }); | |||||
| 403 | }) ; | |||||
| 404 | ||||||
| 405 | de scribe('Se ction View Test', fu nction() { | |||||
| 406 | var sect ionView; | |||||
| 407 | var gas; | |||||
| 408 | ||||||
| 409 | beforeEa ch(functio n() { | |||||
| 410 | var sectionReg ion; | |||||
| 411 | ||||||
| 412 | regi on = helpe rs.setupTe stingRegio n(); | |||||
| 413 | fetc h = helper s.collecti onFetchSpy (); | |||||
| 414 | mode l = create Model(); | |||||
| 415 | ||||||
| 416 | view = new Vie w({ | |||||
| 417 | model: mod el, | |||||
| 418 | typeOfCare Name: TYPE _OF_CARE, | |||||
| 419 | googleAnal yticsProvi der: { | |||||
| 420 | getIns tance: fun ction() { | |||||
| 421 | ga s = jasmin e.createSp yObj('gas' , ['gas']) ; | |||||
| 422 | re turn gas; | |||||
| 423 | }, | |||||
| 424 | }, | |||||
| 425 | }); | |||||
| 426 | prep areClinics Collection (view); | |||||
| 427 | view .collectio n.set(help ers.mockPa tientFacil ity(), {pa rse: true} ); | |||||
| 428 | regi on.show(vi ew); | |||||
| 429 | view .showRegio ns(); | |||||
| 430 | ||||||
| 431 | sect ionRegion = view.get Region('se ction'); | |||||
| 432 | sect ionView = sectionReg ion.curren tView; | |||||
| 433 | }); | |||||
| 434 | ||||||
| 435 | afterEac h(helpers. resetTesti ngRegion); | |||||
| 436 | ||||||
| 437 | it('upda tes its mo del on a c ollection change', f unction() { | |||||
| 438 | var isCalled = false; | |||||
| 439 | var id = 'myVa lue'; | |||||
| 440 | var value = vi ew.collect ion.first( ).get('ins titutionCo de'); | |||||
| 441 | ||||||
| 442 | view .listenTo( view.model , 'change: myValue', function() { | |||||
| 443 | isCalled = true; | |||||
| 444 | }); | |||||
| 445 | ||||||
| 446 | sect ionView.co llection.t rigger('ch ange:value ', new Bac kbone.Mode l({ | |||||
| 447 | id: id, | |||||
| 448 | value: val ue, | |||||
| 449 | })); | |||||
| 450 | ||||||
| 451 | expe ct(isCalle d).toBeTru thy(); | |||||
| 452 | expe ct(gas.gas ).toHaveBe enCalled() ; | |||||
| 453 | }); | |||||
| 454 | ||||||
| 455 | it('shou ld call Go ogle Analy tics when the collec tion chang es upon se lecting a facility', function( ) { | |||||
| 456 | var id = 'id'; | |||||
| 457 | var value = vi ew.collect ion.first( ).get('ins titutionCo de'); | |||||
| 458 | ||||||
| 459 | sect ionView.co llection.t rigger('ch ange:value ', new Bac kbone.Mode l({ | |||||
| 460 | id: id, | |||||
| 461 | value: val ue, | |||||
| 462 | })); | |||||
| 463 | ||||||
| 464 | expe ct(gas.gas ).toHaveBe enCalledWi th('send', 'event', 'veteran-a ppointment ', 'facili ty-selecte d', 'GREEN FIELD (CBO C) (GREENF IELD, MA)' ); | |||||
| 465 | }); | |||||
| 466 | }) ; | |||||
| 467 | }); | |||||
| 468 | ||||||
| 469 | descri be('Schedu ling Facil ity Sectio n View', f unction() { | |||||
| 470 | va r facility QuestionMo delSpy; | |||||
| 471 | ||||||
| 472 | va r setup = function(s ectionData In) { | |||||
| 473 | var faci litiesColl ectionMock ; | |||||
| 474 | var faci lityModelM ock; | |||||
| 475 | var view ; | |||||
| 476 | var goog leAnalytic sProviderM ock; | |||||
| 477 | facility QuestionMo delSpy = j asmine.cre ateSpyObj( 'facilityQ uestionMod elSpy', [' set']); | |||||
| 478 | ||||||
| 479 | faciliti esCollecti onMock = { | |||||
| 480 | toSe ctionData: function () { | |||||
| 481 | return sec tionDataIn ; | |||||
| 482 | }, | |||||
| 483 | }; | |||||
| 484 | facility ModelMock = { | |||||
| 485 | pacT eam: funct ion() { | |||||
| 486 | return {}; | |||||
| 487 | }, | |||||
| 488 | }; | |||||
| 489 | googleAn alyticsPro viderMock = { | |||||
| 490 | getI nstance: f unction() { | |||||
| 491 | return jas mine.creat eSpy('goog leAnalytic sMock', [' gas']); | |||||
| 492 | }, | |||||
| 493 | }; | |||||
| 494 | ||||||
| 495 | view = n ew Section View({ | |||||
| 496 | mode l: facilit yModelMock , | |||||
| 497 | pati entEnrolle dFacilitie s: facilit iesCollect ionMock, | |||||
| 498 | clin icsInstitu tionCodes: [], | |||||
| 499 | goog leAnalytic sProvider: googleAna lyticsProv iderMock, | |||||
| 500 | }); | |||||
| 501 | ||||||
| 502 | view.col lection = { | |||||
| 503 | get: function( property) { | |||||
| 504 | if (proper ty === 'fa cility') { | |||||
| 505 | return facilityQ uestionMod elSpy; | |||||
| 506 | } | |||||
| 507 | return nul l; | |||||
| 508 | }, | |||||
| 509 | }; | |||||
| 510 | ||||||
| 511 | return v iew; | |||||
| 512 | }; | |||||
| 513 | ||||||
| 514 | it ('should p ut the fac ilities wi th PAC Tea ms first i n the drop down', fun ction() { | |||||
| 515 | var faci lity1 = { 'text': 'f acility1', 'hasPactL abel': fal se }; | |||||
| 516 | var faci lity2 = { 'text': 'f acility2', 'hasPactL abel': fal se }; | |||||
| 517 | var faci lity3 = { 'text': 'f acility3', 'hasPactL abel': fal se }; | |||||
| 518 | var faci lity4 = { 'text': 'f acility4', 'hasPactL abel': tru e }; | |||||
| 519 | var faci lity5 = { 'text': 'f acility5', 'hasPactL abel': tru e }; | |||||
| 520 | ||||||
| 521 | var expe ctedOrder = [facilit y4, facili ty5, facil ity1, faci lity2, fac ility3]; | |||||
| 522 | var sect ionDataIn = [facilit y1, facili ty2, facil ity3, faci lity4, fac ility5]; | |||||
| 523 | var view = setup(s ectionData In); | |||||
| 524 | ||||||
| 525 | view.set FacilityQu estionMode l(); | |||||
| 526 | ||||||
| 527 | expect(f acilityQue stionModel Spy.set).t oHaveBeenC alledWith( 'values', expectedOr der); | |||||
| 528 | }) ; | |||||
| 529 | ||||||
| 530 | it ('should s ort the fa cilities a lphabetica lly', func tion() { | |||||
| 531 | var faci lityA = { 'text': 'a ', 'hasPac tLabel': f alse }; | |||||
| 532 | var faci lityB = { 'text': 'b ', 'hasPac tLabel': f alse }; | |||||
| 533 | var faci lityC = { 'text': 'c ', 'hasPac tLabel': f alse }; | |||||
| 534 | ||||||
| 535 | var expe ctedOrder = [facilit yA, facili tyB, facil ityC]; | |||||
| 536 | var sect ionDataIn = [facilit yA, facili tyC, facil ityB]; | |||||
| 537 | var view = setup(s ectionData In); | |||||
| 538 | ||||||
| 539 | view.set FacilityQu estionMode l(); | |||||
| 540 | ||||||
| 541 | expect(f acilityQue stionModel Spy.set).t oHaveBeenC alledWith( 'values', expectedOr der); | |||||
| 542 | }) ; | |||||
| 543 | ||||||
| 544 | }); | |||||
| 545 | }); | |||||
| 546 | TTTT |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.