Produced by Araxis Merge on 3/12/2019 4:22:12 PM 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 | C:\AraxisMergeCompare\Pri_un\CC CC SEOC 1.7\seocui-release1.7@bb33f84589b\cc_seoc_ui\src\components\user-management | UserTable.spec.js | Tue Jan 29 13:55:38 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\Community Care Care Coordination SEOC 1.7-redacted\CC CC SEOC 1.7\seocui-release1.7@bb33f84589b\cc_seoc_ui\src\components\user-management | UserTable.spec.js | Tue Mar 12 21:15:44 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 8 | 1412 |
Changed | 7 | 22 |
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 | import Rea ct from 'r eact'; | |
2 | import { s hallow } f rom 'enzym e'; | |
3 | ||
4 | import { r oleFilterT ypes } fro m '../../c onstants/f ilterTypes '; | |
5 | ||
6 | import Use rTable fro m './UserT able'; | |
7 | import Use rTableHead er from '. /UserTable Header'; | |
8 | import Use rTableRow from './Us erTableRow '; | |
9 | import Use rTableEmpt yRow from './UserTab leEmptyRow '; | |
10 | import Use rTableForm Row from ' ./UserTabl eFormRow'; | |
11 | ||
12 | const gene rateUsers = () => { | |
13 | let gene ratedUsers = []; | |
14 | ||
15 | for (let i = 0; i < 60; i += 1) { | |
16 | const role = rol eFilterTyp es[i % 4]; | |
17 | ||
18 | let us er = { | |
19 | id: `${i + 1}` , | |
20 | user Name: `Use r, ${role} ${i + 1}` , | |
21 | role : role, | |
22 | vaNetworkI d: ' R E DA C TED ', | |
23 | domain: ' RE D ACT E D ' | |
24 | }; | |
25 | ||
26 | genera tedUsers.p ush(user); | |
27 | } | |
28 | ||
29 | return g eneratedUs ers; | |
30 | }; | |
31 | ||
32 | const user s = genera teUsers(); | |
33 | ||
34 | let showEd it; | |
35 | let usersL ist = user s; | |
36 | let update User; | |
37 | let user = { | |
38 | id: '61' , | |
39 | userName: ' RED A CTED ', | |
40 | role: 'A dministrat or', | |
41 | vaNetworkI d: ' RED A CTED ', | |
42 | domain: ' RE D ACT E D ' | |
43 | }; | |
44 | let select ed = null; | |
45 | ||
46 | let focus; | |
47 | ||
48 | describe(' UserTable Component' , () => { | |
49 | let wrap per; | |
50 | let tabl e; | |
51 | ||
52 | let upda teSelected ; | |
53 | ||
54 | const mo untWrapper = () => { | |
55 | wrappe r = shallo w( | |
56 | <Use rTable | |
57 | sh owEdit={sh owEdit} | |
58 | us ers={users List} | |
59 | up dateUser={ updateUser } | |
60 | us er={user} | |
61 | up dateSelect ed={update Selected} | |
62 | se lected={se lected} /> ); | |
63 | table = wrapper. instance() ; | |
64 | }; | |
65 | ||
66 | beforeEa ch(() => { | |
67 | showEd it = false ; | |
68 | update User = jes t.fn(); | |
69 | update Selected = jest.fn() ; | |
70 | focus = jest.fn( ); | |
71 | ||
72 | docume nt.querySe lector = j est.fn().m ockImpleme ntation(() => ({ foc us })); | |
73 | ||
74 | mountW rapper(); | |
75 | }); | |
76 | ||
77 | describe ('elements ', () => { | |
78 | it('sh ould use a UserTable Header', ( ) => { | |
79 | cons t actual = wrapper.f ind(UserTa bleHeader) .length; | |
80 | cons t expected = 1; | |
81 | ||
82 | expe ct(actual) .toEqual(e xpected); | |
83 | }); | |
84 | ||
85 | it('sh ould pass props to t he UserTab leHeader', () => { | |
86 | cons t actual = wrapper.f ind(UserTa bleHeader) .prop('pro ps'); | |
87 | cons t expected = { showE dit: false }; | |
88 | ||
89 | expe ct(actual) .toEqual(e xpected); | |
90 | }); | |
91 | ||
92 | descri be('showEd it is fals e', () => { | |
93 | befo reEach(() => { | |
94 | sh owEdit = f alse; | |
95 | }); | |
96 | ||
97 | it(' should dis play one U serTableRo w for each User', () => { | |
98 | us ersList = users; | |
99 | mo untWrapper (); | |
100 | ||
101 | co nst userTa bleRows = wrapper.fi nd(UserTab leRow); | |
102 | ||
103 | ex pect(userT ableRows.l ength).toE qual(60); | |
104 | ||
105 | us erTableRow s.forEach( (userTable Row, index ) => { | |
106 | updateSele cted.mockR eset(); | |
107 | ||
108 | expect(use rTableRow. key()).toE qual(`${us ers[index] .id}`); | |
109 | expect(use rTableRow. prop('user ')).toEqua l(users[in dex]); | |
110 | expect(use rTableRow. prop('sele cted')).to Equal(tabl e.state.se lected === index); | |
111 | expect(use rTableRow. prop('rowI ndex')).to Equal(inde x); | |
112 | expect(use rTableRow. prop('show Edit')).to Equal(show Edit); | |
113 | ||
114 | userTableR ow.prop('u pdateSelec ted')(); | |
115 | ||
116 | expect(upd ateSelecte d).toBeCal led(); | |
117 | }) ; | |
118 | }); | |
119 | ||
120 | it(' should dis play all o f the user s, even if the user prop match es one of the users' , () => { | |
121 | us ersList = users; | |
122 | us er = users [59]; | |
123 | mo untWrapper (); | |
124 | ||
125 | co nst userTa bleRows = wrapper.fi nd(UserTab leRow); | |
126 | ||
127 | ex pect(userT ableRows.l ength).toE qual(60); | |
128 | ||
129 | us erTableRow s.forEach( (userTable Row, index ) => { | |
130 | expect(use rTableRow. key()).toE qual(`${us ers[index] .id}`); | |
131 | expect(use rTableRow. prop('user ')).toEqua l(users[in dex]); | |
132 | expect(use rTableRow. prop('sele cted')).to Equal(tabl e.state.se lected === index); | |
133 | expect(use rTableRow. prop('rowI ndex')).to Equal(inde x); | |
134 | expect(use rTableRow. prop('show Edit')).to Equal(show Edit); | |
135 | }) ; | |
136 | }); | |
137 | ||
138 | it(' should dis play the U serTableEm ptyRow if the list o f users is empty', ( ) => { | |
139 | us ersList = []; | |
140 | mo untWrapper (); | |
141 | ||
142 | co nst userTa bleRows = wrapper.fi nd(UserTab leRow); | |
143 | co nst userTa bleEmptyRo w = wrappe r.find(Use rTableEmpt yRow); | |
144 | ||
145 | ex pect(userT ableRows.l ength).toE qual(0); | |
146 | ex pect(userT ableEmptyR ow.length) .toEqual(1 ); | |
147 | ex pect(userT ableEmptyR ow.key()). toEqual('1 '); | |
148 | }); | |
149 | }); | |
150 | ||
151 | descri be('showEd it is true ', () => { | |
152 | befo reEach(() => { | |
153 | sh owEdit = t rue; | |
154 | }); | |
155 | ||
156 | it(' should dis play one U serTableFo rm Row, an d one User TableRow f or each Us er', () => { | |
157 | us ersList = users; | |
158 | us er = { | |
159 | id: 61, | |
160 | userName: ' RED A CTED ', | |
161 | role: 'Adm inistrator ', | |
162 | vaNetworkI d: ' RED A CTED ', | |
163 | domain: ' RE D ACT E D ' | |
164 | }; | |
165 | mo untWrapper (); | |
166 | ||
167 | co nst userTa bleFormRow = wrapper .find(User TableFormR ow); | |
168 | co nst userTa bleRows = wrapper.fi nd(UserTab leRow); | |
169 | ||
170 | ex pect(userT ableFormRo w.length). toEqual(1) ; | |
171 | ex pect(userT ableFormRo w.key()).t oEqual('0' ); | |
172 | ex pect(userT ableFormRo w.prop('us er')).toEq ual(user); | |
173 | ||
174 | up dateUser.m ockReset() ; | |
175 | us erTableFor mRow.prop( 'updateUse r')(); | |
176 | ||
177 | ex pect(updat eUser).toB eCalled(); | |
178 | ||
179 | ex pect(userT ableRows.l ength).toE qual(60); | |
180 | ||
181 | us erTableRow s.forEach( (userTable Row, index ) => { | |
182 | updateSele cted.mockR eset(); | |
183 | ||
184 | expect(use rTableRow. key()).toE qual(`${in dex + 1}`) ; | |
185 | expect(use rTableRow. prop('user ')).toEqua l(users[in dex]); | |
186 | expect(use rTableRow. prop('sele cted')).to Equal(tabl e.state.se lected === index); | |
187 | expect(use rTableRow. prop('rowI ndex')).to Equal(inde x); | |
188 | expect(use rTableRow. prop('show Edit')).to Equal(show Edit); | |
189 | ||
190 | userTableR ow.prop('u pdateSelec ted')(); | |
191 | ||
192 | expect(upd ateSelecte d).toBeCal led(); | |
193 | }) ; | |
194 | }); | |
195 | ||
196 | it(' should not display a row that matches th e current user prop' , () => { | |
197 | us ersList = users; | |
198 | us er = users [59]; | |
199 | mo untWrapper (); | |
200 | ||
201 | co nst userTa bleRows = wrapper.fi nd(UserTab leRow); | |
202 | ||
203 | ex pect(userT ableRows.l ength).toE qual(59); | |
204 | ||
205 | us erTableRow s.forEach( (userTable Row) => { | |
206 | expect(use rTableRow. prop('user ')).not.to Equal(user ); | |
207 | }) ; | |
208 | }); | |
209 | ||
210 | it(' should dis play one U serTableFo rmRow, and the UserT ableEmptyR ow if the list of us ers is emp ty', () => { | |
211 | us ersList = []; | |
212 | mo untWrapper (); | |
213 | ||
214 | co nst userTa bleFormRow = wrapper .find(User TableFormR ow); | |
215 | co nst userTa bleRows = wrapper.fi nd(UserTab leRow); | |
216 | co nst userTa bleEmptyRo w = wrappe r.find(Use rTableEmpt yRow); | |
217 | ||
218 | ex pect(userT ableFormRo w.length). toEqual(1) ; | |
219 | ex pect(userT ableFormRo w.key()).t oEqual('0' ); | |
220 | ex pect(userT ableFormRo w.prop('us er')).toEq ual(user); | |
221 | ||
222 | up dateUser.m ockReset() ; | |
223 | us erTableFor mRow.prop( 'updateUse r')(); | |
224 | ||
225 | ex pect(userT ableRows.l ength).toE qual(0); | |
226 | ex pect(userT ableEmptyR ow.length) .toEqual(1 ); | |
227 | ex pect(userT ableEmptyR ow.key()). toEqual('1 '); | |
228 | }); | |
229 | }); | |
230 | }); | |
231 | ||
232 | describe ('componen tDidUpdate ', () => { | |
233 | before Each(() => { | |
234 | user sList = us ers; | |
235 | ||
236 | tabl e.updateSe lectedIfVi sible = je st.fn(); | |
237 | ||
238 | wrap per.setPro ps({ users : usersLis t }); | |
239 | ||
240 | tabl e.updateSe lectedIfVi sible.mock Reset(); | |
241 | }); | |
242 | ||
243 | it('sh ould not c all update SelectedIf Visible if the users prop is h as not cha nged', () => { | |
244 | user sList = us ers; | |
245 | ||
246 | wrap per.setPro ps({ users : usersLis t }); | |
247 | ||
248 | expe ct(table.u pdateSelec tedIfVisib le).not.to BeCalled() ; | |
249 | }); | |
250 | ||
251 | it('sh ould call updateSele ctedIfVisi ble if the users pro p has chan ged', () = > { | |
252 | user sList = [{ | |
253 | id : 61, | |
254 | userName: ' RED A CTED ', | |
255 | ro le: 'Admin istrator', | |
256 | vaNetworkI d: ' RED A CTED ', | |
257 | domain: ' RE D ACT E D ' | |
258 | }]; | |
259 | ||
260 | wrap per.setPro ps({ users : usersLis t }); | |
261 | ||
262 | expe ct(table.u pdateSelec tedIfVisib le).toBeCa lled(); | |
263 | }); | |
264 | }); | |
265 | ||
266 | describe ('updateSe lectedIfVi sible', () => { | |
267 | let sc rollIntoVi ew; | |
268 | ||
269 | before Each(() => { | |
270 | user sList = us ers; | |
271 | ||
272 | tabl e.updateSe lected = j est.fn(); | |
273 | ||
274 | wrap per.setPro ps({ users }); | |
275 | ||
276 | tabl e.updateSe lected.moc kReset(); | |
277 | ||
278 | tabl e.setState ({ selecte d: 0 }); | |
279 | }); | |
280 | ||
281 | it('sh ould call updateSele cted with 0', () => { | |
282 | wrap per.setPro ps({ selec ted: '65' }); | |
283 | ||
284 | tabl e.updateSe lectedIfVi sible(); | |
285 | ||
286 | cons t actual = table.upd ateSelecte d.mock.cal ls[0][0]; | |
287 | cons t expected = 0; | |
288 | ||
289 | expe ct(table.u pdateSelec ted).toBeC alled(); | |
290 | expe ct(actual) .toEqual(e xpected); | |
291 | }); | |
292 | ||
293 | it('sh ould scrol l the sele cted row i nto view a fter updat ing the se lected SEO C', () => { | |
294 | wrap per.setPro ps({ selec ted: '0' } ); | |
295 | ||
296 | scro llIntoView = jest.fn (); | |
297 | ||
298 | docu ment.query Selector = jest.fn() .mockImple mentation( () => ({ s crollIntoV iew })); | |
299 | ||
300 | tabl e.updateSe lectedIfVi sible(); | |
301 | ||
302 | cons t afterUpd ate = tabl e.updateSe lected.moc k.calls[0] [1]; | |
303 | ||
304 | expe ct(table.u pdateSelec ted).toBeC alled(); | |
305 | expe ct(documen t.querySel ector).not .toBeCalle d(); | |
306 | ||
307 | afte rUpdate(); | |
308 | ||
309 | expe ct(documen t.querySel ector).toB eCalledWit h('.highli ght'); | |
310 | expe ct(scrollI ntoView).t oBeCalled( ); | |
311 | }); | |
312 | ||
313 | descri be('users list is em pty', () = > { | |
314 | befo reEach(() => { | |
315 | us ersList = []; | |
316 | up dateSelect ed = jest. fn(); | |
317 | mo untWrapper (); | |
318 | ||
319 | ta ble.setSta te({ selec ted: 0 }); | |
320 | ||
321 | ta ble.update Selected = jest.fn() ; | |
322 | ta ble.update SelectedIf Visible(); | |
323 | }); | |
324 | ||
325 | it(' should set selected on the sta te to null ', () => { | |
326 | co nst actual = table.s tate.selec ted; | |
327 | co nst expect ed = null; | |
328 | ||
329 | ex pect(actua l).toEqual (expected) ; | |
330 | }); | |
331 | ||
332 | it(' should cal l the upda teSelected prop with null', () => { | |
333 | ex pect(updat eSelected) .toBeCalle dWith(null ); | |
334 | }); | |
335 | ||
336 | it(' should not call the local upda teSelected function' , () => { | |
337 | ex pect(table .updateSel ected).not .toBeCalle d(); | |
338 | }); | |
339 | }); | |
340 | }); | |
341 | ||
342 | describe ('updateSe lected', ( ) => { | |
343 | before Each(() => { | |
344 | user sList = us ers; | |
345 | moun tWrapper() ; | |
346 | }); | |
347 | ||
348 | it('sh ould defau lt selecte d to null' , () => { | |
349 | cons t actual = table.sta te.selecte d; | |
350 | cons t expected = null; | |
351 | ||
352 | expe ct(actual) .toEqual(e xpected); | |
353 | }); | |
354 | ||
355 | it('sh ould updat e selected ', () => { | |
356 | cons t newIndex = 2; | |
357 | ||
358 | tabl e.updateSe lected(new Index); | |
359 | ||
360 | cons t actual = table.sta te.selecte d; | |
361 | cons t expected = newInde x; | |
362 | ||
363 | expe ct(actual) .toEqual(e xpected); | |
364 | }); | |
365 | ||
366 | it('sh ould call the given function a fter updat ing select ed', () => { | |
367 | cons t newIndex = 2; | |
368 | cons t afterUpd ate = jest .fn(); | |
369 | ||
370 | tabl e.updateSe lected(new Index, aft erUpdate); | |
371 | ||
372 | expe ct(afterUp date).toBe Called(); | |
373 | }); | |
374 | ||
375 | it('sh ould call the update Selected p rop with t he id of t he selecte d SEOC', ( ) => { | |
376 | cons t newIndex = 2; | |
377 | ||
378 | tabl e.updateSe lected(new Index); | |
379 | ||
380 | expe ct(updateS elected).t oBeCalledW ith(users[ newIndex]. id); | |
381 | }); | |
382 | }); | |
383 | ||
384 | describe ('focusSel ected', () => { | |
385 | it('sh ould focus on the se lected row ', () => { | |
386 | let focus = je st.fn(); | |
387 | let scrollInto View = jes t.fn(); | |
388 | ||
389 | docu ment.query Selector = jest.fn() .mockImple mentation( () => ({ | |
390 | fo cus, | |
391 | sc rollIntoVi ew | |
392 | })); | |
393 | ||
394 | tabl e.setState ({ selecte d: 2 }); | |
395 | ||
396 | tabl e.focusSel ected(); | |
397 | ||
398 | expe ct(documen t.querySel ector).toB eCalledWit h('table.s eoc-table tbody tr:n th-child(3 )'); | |
399 | expe ct(focus). toBeCalled (); | |
400 | }); | |
401 | ||
402 | it('sh ould call scrollInto View, when focusing on the sel ected row' , () => { | |
403 | let focus = je st.fn(); | |
404 | let scrollInto View = jes t.fn(); | |
405 | ||
406 | docu ment.query Selector = jest.fn() .mockImple mentation( () => ({ | |
407 | fo cus, | |
408 | sc rollIntoVi ew | |
409 | })); | |
410 | ||
411 | tabl e.setState ({ selecte d: 2 }); | |
412 | ||
413 | tabl e.focusSel ected(); | |
414 | ||
415 | expe ct(scrollI ntoView).t oBeCalledW ith(true); | |
416 | }); | |
417 | }); | |
418 | ||
419 | describe ('key down events', () => { | |
420 | let pr eventDefau lt; | |
421 | ||
422 | descri be('showEd it is fals e', () => { | |
423 | befo reEach(() => { | |
424 | sh owEdit = f alse; | |
425 | mo untWrapper (); | |
426 | ||
427 | ta ble.update Selected = jest.fn() ; | |
428 | ta ble.focusS elected = jest.fn(); | |
429 | pr eventDefau lt = jest. fn(); | |
430 | }); | |
431 | ||
432 | desc ribe('arro w up', () => { | |
433 | it ('should m ove select ed to the previous r ow if sele cted is no t the firs t row', () => { | |
434 | const curr Selected = 2; | |
435 | ||
436 | table.setS tate({ sel ected: cur rSelected }); | |
437 | ||
438 | table.hand leKeyDown( { | |
439 | which: 3 8, | |
440 | preventD efault | |
441 | }); | |
442 | ||
443 | expect(tab le.updateS elected).t oBeCalled( ); | |
444 | ||
445 | const para ms = table .updateSel ected.mock .calls[0]; | |
446 | ||
447 | expect(par ams[0]).to Equal(curr Selected - 1); | |
448 | ||
449 | params[1]( ); | |
450 | expect(tab le.focusSe lected).to BeCalled() ; | |
451 | }) ; | |
452 | ||
453 | it ('should n ot move to the previ ous row if selected is the fir st row', ( ) => { | |
454 | const curr Selected = 0; | |
455 | ||
456 | table.setS tate({ sel ected: cur rSelected }); | |
457 | ||
458 | table.hand leKeyDown( { | |
459 | which: 3 8, | |
460 | preventD efault | |
461 | }); | |
462 | ||
463 | expect(tab le.updateS elected).n ot.toBeCal led(); | |
464 | expect(tab le.focusSe lected).no t.toBeCall ed(); | |
465 | }) ; | |
466 | }); | |
467 | ||
468 | desc ribe('arro w down', ( ) => { | |
469 | it ('should m ove select ed to the next row i f selected is not th e last row ', () => { | |
470 | const curr Selected = 0; | |
471 | ||
472 | table.setS tate({ sel ected: cur rSelected }); | |
473 | ||
474 | table.hand leKeyDown( { | |
475 | which: 4 0, | |
476 | preventD efault | |
477 | }); | |
478 | ||
479 | expect(tab le.updateS elected).t oBeCalled( ); | |
480 | ||
481 | const para ms = table .updateSel ected.mock .calls[0]; | |
482 | ||
483 | expect(par ams[0]).to Equal(curr Selected + 1); | |
484 | ||
485 | params[1]( ); | |
486 | expect(tab le.focusSe lected).to BeCalled() ; | |
487 | }) ; | |
488 | ||
489 | it ('should n ot move to the next row if sel ected is t he last ro w', () => { | |
490 | const curr Selected = wrapper.f ind(UserTa bleRow).le ngth - 1; | |
491 | ||
492 | table.setS tate({ sel ected: cur rSelected }); | |
493 | ||
494 | table.hand leKeyDown( { | |
495 | which: 4 0, | |
496 | preventD efault | |
497 | }); | |
498 | ||
499 | const actu al = table .state.sel ected; | |
500 | const expe cted = cur rSelected; | |
501 | ||
502 | expect(act ual).toEqu al(expecte d); | |
503 | ||
504 | expect(tab le.updateS elected).n ot.toBeCal led(); | |
505 | expect(tab le.focusSe lected).no t.toBeCall ed(); | |
506 | }) ; | |
507 | }); | |
508 | ||
509 | desc ribe('page up', () = > { | |
510 | it ('should c all preven tDefault, when pagin g up', () => { | |
511 | const curr Selected = 12; | |
512 | ||
513 | table.setS tate({ sel ected: cur rSelected }); | |
514 | ||
515 | table.hand leKeyDown( { | |
516 | which: 3 3, | |
517 | preventD efault | |
518 | }); | |
519 | ||
520 | expect(pre ventDefaul t).toBeCal led(); | |
521 | }) ; | |
522 | ||
523 | it ('should m ove select ed up to t he row spe cified by the offset ', () => { | |
524 | const curr Selected = 12; | |
525 | ||
526 | table.setS tate({ sel ected: cur rSelected }); | |
527 | ||
528 | table.hand leKeyDown( { | |
529 | which: 3 3, | |
530 | preventD efault | |
531 | }); | |
532 | ||
533 | expect(tab le.updateS elected).t oBeCalled( ); | |
534 | ||
535 | const para ms = table .updateSel ected.mock .calls[0]; | |
536 | ||
537 | expect(par ams[0]).to Equal(2); | |
538 | ||
539 | params[1]( ); | |
540 | expect(tab le.focusSe lected).to BeCalled() ; | |
541 | }) ; | |
542 | ||
543 | it ('should m ove select ed up to t he first r ow if the index of t he selecte d row is l ess than t he offset' , () => { | |
544 | const curr Selected = 5; | |
545 | ||
546 | table.setS tate({ sel ected: cur rSelected }); | |
547 | ||
548 | table.hand leKeyDown( { | |
549 | which: 3 3, | |
550 | preventD efault | |
551 | }); | |
552 | ||
553 | expect(tab le.updateS elected).t oBeCalled( ); | |
554 | ||
555 | const para ms = table .updateSel ected.mock .calls[0]; | |
556 | ||
557 | expect(par ams[0]).to Equal(0); | |
558 | ||
559 | params[1]( ); | |
560 | expect(tab le.focusSe lected).to BeCalled() ; | |
561 | }) ; | |
562 | ||
563 | it ('should n ot move to the previ ous row, i f the sele cted row i s the firs t row', () => { | |
564 | const curr Selected = 0; | |
565 | ||
566 | table.setS tate({ sel ected: cur rSelected }); | |
567 | ||
568 | table.hand leKeyDown( { | |
569 | which: 3 3, | |
570 | preventD efault | |
571 | }); | |
572 | ||
573 | expect(tab le.updateS elected).t oBeCalled( ); | |
574 | ||
575 | const para ms = table .updateSel ected.mock .calls[0]; | |
576 | ||
577 | expect(par ams[0]).to Equal(0); | |
578 | ||
579 | params[1]( ); | |
580 | expect(tab le.focusSe lected).to BeCalled() ; | |
581 | }) ; | |
582 | }); | |
583 | ||
584 | desc ribe('page down', () => { | |
585 | it ('should c all preven tDefault, when pagin g down', ( ) => { | |
586 | const curr Selected = 0; | |
587 | ||
588 | table.setS tate({ sel ected: cur rSelected }); | |
589 | ||
590 | table.hand leKeyDown( { | |
591 | which: 3 4, | |
592 | preventD efault | |
593 | }); | |
594 | ||
595 | expect(pre ventDefaul t).toBeCal led(); | |
596 | }) ; | |
597 | ||
598 | it ('should m ove select ed down to the row s pecified b y the offs et', () => { | |
599 | const curr Selected = 0; | |
600 | ||
601 | table.setS tate({ sel ected: cur rSelected }); | |
602 | ||
603 | table.hand leKeyDown( { | |
604 | which: 3 4, | |
605 | preventD efault | |
606 | }); | |
607 | ||
608 | expect(tab le.updateS elected).t oBeCalled( ); | |
609 | ||
610 | const para ms = table .updateSel ected.mock .calls[0]; | |
611 | ||
612 | expect(par ams[0]).to Equal(tabl e.state.of fset); | |
613 | ||
614 | params[1]( ); | |
615 | expect(tab le.focusSe lected).to BeCalled() ; | |
616 | }) ; | |
617 | ||
618 | it ('should m ove select ed down to the last row if the number of rows rema ining is l ess than t he offset' , () => { | |
619 | const curr Selected = 55; | |
620 | ||
621 | table.setS tate({ sel ected: cur rSelected }); | |
622 | ||
623 | table.hand leKeyDown( { | |
624 | which: 3 4, | |
625 | preventD efault | |
626 | }); | |
627 | ||
628 | expect(tab le.updateS elected).t oBeCalled( ); | |
629 | ||
630 | const para ms = table .updateSel ected.mock .calls[0]; | |
631 | ||
632 | expect(par ams[0]).to Equal(59); | |
633 | ||
634 | params[1]( ); | |
635 | expect(tab le.focusSe lected).to BeCalled() ; | |
636 | }) ; | |
637 | ||
638 | it ('should n ot move to the next row, if th e selected row is th e last row ', () => { | |
639 | const curr Selected = 59; | |
640 | ||
641 | table.setS tate({ sel ected: cur rSelected }); | |
642 | ||
643 | table.hand leKeyDown( { | |
644 | which: 3 4, | |
645 | preventD efault | |
646 | }); | |
647 | ||
648 | expect(tab le.updateS elected).t oBeCalled( ); | |
649 | ||
650 | const para ms = table .updateSel ected.mock .calls[0]; | |
651 | ||
652 | expect(par ams[0]).to Equal(59); | |
653 | ||
654 | params[1]( ); | |
655 | expect(tab le.focusSe lected).to BeCalled() ; | |
656 | }) ; | |
657 | }); | |
658 | }); | |
659 | ||
660 | descri be('showEd it is true ', () => { | |
661 | befo reEach(() => { | |
662 | sh owEdit = t rue; | |
663 | mo untWrapper (); | |
664 | ||
665 | ta ble.update Selected = jest.fn() ; | |
666 | ta ble.focusS elected = jest.fn(); | |
667 | ta ble.handle PageUpFocu s = jest.f n(); | |
668 | ta ble.handle PageDownFo cus = jest .fn(); | |
669 | pr eventDefau lt = jest. fn(); | |
670 | ||
671 | ta ble.setSta te({ selec ted: 2 }); | |
672 | }); | |
673 | ||
674 | it(' should not call the arrow up e vent', () => { | |
675 | ta ble.handle KeyDown({ | |
676 | which: 38, | |
677 | preventDef ault | |
678 | }) ; | |
679 | ||
680 | ex pect(preve ntDefault) .not.toBeC alled(); | |
681 | ex pect(table .updateSel ected).not .toBeCalle d(); | |
682 | ex pect(table .focusSele cted).not. toBeCalled (); | |
683 | }); | |
684 | ||
685 | it(' should not call the arrow down event', ( ) => { | |
686 | ta ble.handle KeyDown({ | |
687 | which: 40, | |
688 | preventDef ault | |
689 | }) ; | |
690 | ||
691 | ex pect(preve ntDefault) .not.toBeC alled(); | |
692 | ex pect(table .updateSel ected).not .toBeCalle d(); | |
693 | ex pect(table .focusSele cted).not. toBeCalled (); | |
694 | }); | |
695 | ||
696 | it(' should not call the page up ev ent', () = > { | |
697 | ta ble.handle KeyDown({ | |
698 | which: 33, | |
699 | preventDef ault | |
700 | }) ; | |
701 | ||
702 | ex pect(preve ntDefault) .not.toBeC alled(); | |
703 | ex pect(table .handlePag eUpFocus). not.toBeCa lled(); | |
704 | }); | |
705 | ||
706 | it(' should not call the page up ev ent', () = > { | |
707 | ta ble.handle KeyDown({ | |
708 | which: 34, | |
709 | preventDef ault | |
710 | }) ; | |
711 | ||
712 | ex pect(preve ntDefault) .not.toBeC alled(); | |
713 | ex pect(table .handlePag eDownFocus ).not.toBe Called(); | |
714 | }); | |
715 | }); | |
716 | }); | |
717 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.