Core_selection.spec.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579
  1. describe('Core_selection', () => {
  2. const id = 'testContainer';
  3. beforeEach(function() {
  4. this.$container = $(`<div id="${id}"></div>`).appendTo('body');
  5. });
  6. afterEach(function() {
  7. if (this.$container) {
  8. destroy();
  9. this.$container.remove();
  10. }
  11. });
  12. it('should correctly render the selection using event simulation', () => {
  13. handsontable({
  14. data: Handsontable.helper.createSpreadsheetObjectData(9, 8),
  15. selectionMode: 'multiple',
  16. colHeaders: true,
  17. rowHeaders: true,
  18. });
  19. $(getCell(5, 4)).simulate('mousedown');
  20. $(getCell(1, 1)).simulate('mouseover');
  21. $(getCell(1, 1)).simulate('mouseup');
  22. keyDown('ctrl');
  23. $(getCell(0, 2)).simulate('mousedown');
  24. $(getCell(8, 2)).simulate('mouseover');
  25. $(getCell(7, 2)).simulate('mouseup');
  26. $(getCell(2, 4)).simulate('mousedown');
  27. $(getCell(2, 4)).simulate('mouseover');
  28. $(getCell(2, 4)).simulate('mouseup');
  29. $(getCell(7, 6)).simulate('mousedown');
  30. $(getCell(8, 7)).simulate('mouseover');
  31. $(getCell(8, 7)).simulate('mouseup');
  32. expect(`
  33. | ║ : - : - : - : - : : - : - |
  34. |===:===:===:===:===:===:===:===:===|
  35. | - ║ : : 0 : : : : : |
  36. | - ║ : 0 : 1 : 0 : 0 : : : |
  37. | - ║ : 0 : 1 : 0 : 1 : : : |
  38. | - ║ : 0 : 1 : 0 : 0 : : : |
  39. | - ║ : 0 : 1 : 0 : 0 : : : |
  40. | - ║ : 0 : 1 : 0 : 0 : : : |
  41. | - ║ : : 0 : : : : : |
  42. | - ║ : : 0 : : : : A : 0 |
  43. | - ║ : : 0 : : : : 0 : 0 |
  44. `).toBeMatchToSelectionPattern();
  45. });
  46. it('should focus external textarea when clicked during editing', () => {
  47. const textarea = $('<input type="text">').prependTo($('body'));
  48. handsontable();
  49. selectCell(0, 0);
  50. keyDown('enter');
  51. // $("html").triggerHandler('mouseup');
  52. $('html').simulate('mouseup');
  53. textarea.focus();
  54. expect(document.activeElement).toBe(textarea[0]);
  55. textarea.remove();
  56. });
  57. it('should deselect currently selected cell', () => {
  58. handsontable();
  59. selectCell(0, 0);
  60. $('html').simulate('mousedown');
  61. expect(getSelected()).toBeUndefined();
  62. });
  63. it('should fix start range if provided is out of bounds (to the left)', () => {
  64. handsontable({
  65. startRows: 5,
  66. startCols: 5,
  67. autoWrapCol: false,
  68. autoWrapRow: false
  69. });
  70. selectCell(0, 0);
  71. keyDownUp('arrow_left');
  72. expect(getSelected()).toEqual([[0, 0, 0, 0]]);
  73. });
  74. it('should fix start range if provided is out of bounds (to the top)', () => {
  75. handsontable({
  76. startRows: 5,
  77. startCols: 5,
  78. autoWrapCol: false,
  79. autoWrapRow: false
  80. });
  81. selectCell(0, 0);
  82. keyDownUp('arrow_up');
  83. expect(getSelected()).toEqual([[0, 0, 0, 0]]);
  84. });
  85. it('should fix start range if provided is out of bounds (to the right)', () => {
  86. handsontable({
  87. startRows: 5,
  88. startCols: 5,
  89. autoWrapCol: false,
  90. autoWrapRow: false
  91. });
  92. selectCell(0, 4);
  93. keyDownUp('arrow_right');
  94. expect(getSelected()).toEqual([[0, 4, 0, 4]]);
  95. });
  96. it('should fix start range if provided is out of bounds (to the bottom)', () => {
  97. handsontable({
  98. startRows: 5,
  99. startCols: 5,
  100. autoWrapCol: false,
  101. autoWrapRow: false
  102. });
  103. selectCell(4, 0);
  104. keyDownUp('arrow_down');
  105. expect(getSelected()).toEqual([[4, 0, 4, 0]]);
  106. });
  107. it('should fix end range if provided is out of bounds (to the left)', () => {
  108. handsontable({
  109. startRows: 5,
  110. startCols: 5
  111. });
  112. selectCell(0, 1);
  113. keyDownUp('shift+arrow_left');
  114. keyDownUp('shift+arrow_left');
  115. expect(getSelected()).toEqual([[0, 1, 0, 0]]);
  116. });
  117. it('should fix end range if provided is out of bounds (to the top)', () => {
  118. handsontable({
  119. startRows: 5,
  120. startCols: 5
  121. });
  122. selectCell(1, 0);
  123. keyDownUp('shift+arrow_up');
  124. keyDownUp('shift+arrow_up');
  125. expect(getSelected()).toEqual([[1, 0, 0, 0]]);
  126. });
  127. it('should fix end range if provided is out of bounds (to the right)', () => {
  128. handsontable({
  129. startRows: 5,
  130. startCols: 5
  131. });
  132. selectCell(0, 3);
  133. keyDownUp('shift+arrow_right');
  134. keyDownUp('shift+arrow_right');
  135. expect(getSelected()).toEqual([[0, 3, 0, 4]]);
  136. });
  137. it('should fix end range if provided is out of bounds (to the bottom)', () => {
  138. handsontable({
  139. startRows: 5,
  140. startCols: 5
  141. });
  142. selectCell(3, 0);
  143. keyDownUp('shift+arrow_down');
  144. keyDownUp('shift+arrow_down');
  145. keyDownUp('shift+arrow_down');
  146. expect(getSelected()).toEqual([[3, 0, 4, 0]]);
  147. });
  148. it('should select multiple cells', () => {
  149. handsontable({
  150. startRows: 5,
  151. startCols: 5
  152. });
  153. selectCell(3, 0, 4, 1);
  154. expect(getSelected()).toEqual([[3, 0, 4, 1]]);
  155. });
  156. it('should call onSelectionEnd as many times as onSelection when `selectCell` is called', () => {
  157. let tick = 0;
  158. let tickEnd = 0;
  159. handsontable({
  160. startRows: 5,
  161. startCols: 5,
  162. afterSelection() {
  163. tick += 1;
  164. },
  165. afterSelectionEnd() {
  166. tickEnd += 1;
  167. }
  168. });
  169. selectCell(3, 0);
  170. selectCell(1, 1);
  171. expect(tick).toEqual(2);
  172. expect(tickEnd).toEqual(2);
  173. });
  174. it('should call onSelectionEnd when user finishes selection by releasing SHIFT key (3 times)', () => {
  175. let tick = 0;
  176. handsontable({
  177. startRows: 5,
  178. startCols: 5,
  179. afterSelectionEnd() {
  180. tick += 1;
  181. }
  182. });
  183. selectCell(3, 0); // makes tick++
  184. keyDownUp('shift+arrow_down'); // makes tick++
  185. keyDownUp('shift+arrow_down'); // makes tick++
  186. keyDownUp('shift+arrow_down'); // makes tick++
  187. expect(getSelected()).toEqual([[3, 0, 4, 0]]);
  188. expect(tick).toEqual(4);
  189. });
  190. it('should call onSelectionEnd when user finishes selection by releasing SHIFT key (1 time)', () => {
  191. let tick = 0;
  192. handsontable({
  193. startRows: 5,
  194. startCols: 5,
  195. afterSelectionEnd() {
  196. tick += 1;
  197. }
  198. });
  199. selectCell(3, 0); // makes tick++
  200. keyDown('shift+arrow_down');
  201. keyDown('shift+arrow_down');
  202. keyDownUp('shift+arrow_down'); // makes tick++
  203. expect(getSelected()).toEqual([[3, 0, 4, 0]]);
  204. expect(tick).toEqual(2);
  205. });
  206. it('should select columns by click on header with SHIFT key', () => {
  207. handsontable({
  208. startRows: 5,
  209. startCols: 5,
  210. colHeaders: true
  211. });
  212. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mousedown');
  213. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mouseup');
  214. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mousedown', { shiftKey: true });
  215. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mouseup');
  216. expect(getSelected()).toEqual([[0, 1, 4, 4]]);
  217. });
  218. it('should select rows by click on header with SHIFT key', () => {
  219. handsontable({
  220. startRows: 5,
  221. startCols: 5,
  222. rowHeaders: true
  223. });
  224. spec().$container.find('.ht_clone_left tr:eq(1) th:eq(0)').simulate('mousedown');
  225. spec().$container.find('.ht_clone_left tr:eq(1) th:eq(0)').simulate('mouseup');
  226. spec().$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mousedown', { shiftKey: true });
  227. spec().$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mouseup');
  228. expect(getSelected()).toEqual([[1, 0, 4, 4]]);
  229. });
  230. it('should select columns by click on header with SHIFT key', () => {
  231. handsontable({
  232. startRows: 5,
  233. startCols: 5,
  234. colHeaders: true
  235. });
  236. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mousedown');
  237. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(1)').simulate('mouseup');
  238. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mousedown', { shiftKey: true });
  239. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mouseup');
  240. expect(getSelected()).toEqual([[0, 1, 4, 4]]);
  241. });
  242. it('should change selection after click on row header with SHIFT key', () => {
  243. handsontable({
  244. startRows: 5,
  245. startCols: 5,
  246. rowHeaders: true
  247. });
  248. selectCell(1, 1, 3, 3);
  249. spec().$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mousedown', { shiftKey: true });
  250. spec().$container.find('.ht_clone_left tr:eq(4) th:eq(0)').simulate('mouseup');
  251. expect(getSelected()).toEqual([[1, 0, 4, 4]]);
  252. });
  253. it('should change selection after click on column header with SHIFT key', () => {
  254. handsontable({
  255. startRows: 5,
  256. startCols: 5,
  257. colHeaders: true
  258. });
  259. selectCell(1, 1, 3, 3);
  260. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mousedown', { shiftKey: true });
  261. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(4)').simulate('mouseup');
  262. expect(getSelected()).toEqual([[0, 1, 4, 4]]);
  263. });
  264. it('should call onSelection while user selects cells with mouse; onSelectionEnd when user finishes selection', () => {
  265. let tick = 0;
  266. let tickEnd = 0;
  267. handsontable({
  268. startRows: 5,
  269. startCols: 5,
  270. afterSelection() {
  271. tick += 1;
  272. },
  273. afterSelectionEnd() {
  274. tickEnd += 1;
  275. }
  276. });
  277. spec().$container.find('tr:eq(0) td:eq(0)').simulate('mousedown');
  278. spec().$container.find('tr:eq(0) td:eq(1)').simulate('mouseover');
  279. spec().$container.find('tr:eq(1) td:eq(3)').simulate('mouseover');
  280. spec().$container.find('tr:eq(1) td:eq(3)').simulate('mouseup');
  281. expect(getSelected()).toEqual([[0, 0, 1, 3]]);
  282. expect(tick).toEqual(3);
  283. expect(tickEnd).toEqual(1);
  284. });
  285. it('should properly select columns, when the user moves the cursor over column headers across two overlays', () => {
  286. handsontable({
  287. startRows: 5,
  288. startCols: 5,
  289. colHeaders: true,
  290. fixedColumnsLeft: 2
  291. });
  292. spec().$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mousedown');
  293. spec().$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mouseover');
  294. spec().$container.find('.ht_clone_top tr:eq(0) th:eq(2)').simulate('mouseover');
  295. spec().$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mouseover');
  296. spec().$container.find('.ht_clone_left tr:eq(0) th:eq(1)').simulate('mouseup');
  297. expect(getSelected()).toEqual([[0, 1, 4, 1]]);
  298. });
  299. it('should move focus to selected cell', () => {
  300. const $input = $('<input>').appendTo(document.body);
  301. handsontable({
  302. startRows: 5,
  303. startCols: 5
  304. });
  305. $input[0].focus();
  306. selectCell(0, 0);
  307. keyDownUp('enter');
  308. expect(isEditorVisible()).toEqual(true);
  309. $input.remove();
  310. });
  311. // This test should cover the #893 case, but it always passes. It seems like the keydown event (with CTRL key pressed) isn't delivered.
  312. it('should not move focus from outside elements on CTRL keydown event, when no cell is selected', () => {
  313. const $input = $('<input type="text"/>');
  314. $('body').append($input);
  315. handsontable();
  316. selectCell(0, 0);
  317. expect(document.activeElement.nodeName).toBeInArray(['TEXTAREA', 'BODY', 'HTML']);
  318. $input.focus();
  319. expect(document.activeElement.nodeName).toBe('INPUT');
  320. $input.simulate('keydown', { ctrlKey: true, metaKey: true });
  321. expect(document.activeElement.nodeName).toBe('INPUT');
  322. $input.remove();
  323. });
  324. it('should select the entire column after column header is clicked', () => {
  325. handsontable({
  326. width: 200,
  327. height: 100,
  328. startRows: 10,
  329. startCols: 5,
  330. colHeaders: true
  331. });
  332. spec().$container.find('thead th:eq(0)').simulate('mousedown');
  333. expect(getSelected()).toEqual([[0, 0, 9, 0]]);
  334. expect(`
  335. | * : : : : |
  336. |===:===:===:===:===|
  337. | A : : : : |
  338. | 0 : : : : |
  339. | 0 : : : : |
  340. | 0 : : : : |
  341. | 0 : : : : |
  342. | 0 : : : : |
  343. | 0 : : : : |
  344. | 0 : : : : |
  345. | 0 : : : : |
  346. | 0 : : : : |
  347. `).toBeMatchToSelectionPattern();
  348. });
  349. it('should select the entire column and row after column header and row header is clicked', () => {
  350. handsontable({
  351. width: 200,
  352. height: 100,
  353. startRows: 10,
  354. startCols: 5,
  355. colHeaders: true,
  356. rowHeaders: true,
  357. });
  358. spec().$container.find('thead th:eq(3)').simulate('mousedown');
  359. keyDown('ctrl');
  360. spec().$container.find('tr:eq(2) th:eq(0)').simulate('mousedown');
  361. expect(`
  362. | ║ - : - : * : - : - |
  363. |===:===:===:===:===:===|
  364. | - ║ : : 0 : : |
  365. | * ║ A : 0 : 1 : 0 : 0 |
  366. | - ║ : : 0 : : |
  367. | - ║ : : 0 : : |
  368. | - ║ : : 0 : : |
  369. | - ║ : : 0 : : |
  370. | - ║ : : 0 : : |
  371. | - ║ : : 0 : : |
  372. | - ║ : : 0 : : |
  373. | - ║ : : 0 : : |
  374. `).toBeMatchToSelectionPattern();
  375. });
  376. it('should select the entire column and row after column header and row header is clicked when cell editor is open', () => {
  377. handsontable({
  378. width: 200,
  379. height: 100,
  380. startRows: 5,
  381. startCols: 5,
  382. colHeaders: true,
  383. rowHeaders: true,
  384. });
  385. selectCell(0, 0);
  386. keyDownUp('enter');
  387. expect(getActiveEditor()).not.toBeUndefined();
  388. keyDown('ctrl');
  389. spec().$container.find('thead th:eq(3)').simulate('mousedown');
  390. spec().$container.find('tr:eq(3) th:eq(0)').simulate('mousedown');
  391. expect(`
  392. | ║ - : - : * : - : - |
  393. |===:===:===:===:===:===|
  394. | - ║ 0 : : 0 : : |
  395. | - ║ : : 0 : : |
  396. | * ║ A : 0 : 1 : 0 : 0 |
  397. | - ║ : : 0 : : |
  398. | - ║ : : 0 : : |
  399. `).toBeMatchToSelectionPattern();
  400. });
  401. it('should not overwrite background color of the cells with custom CSS classes', () => {
  402. handsontable({
  403. width: 300,
  404. height: 150,
  405. startRows: 5,
  406. startCols: 5,
  407. cells: (row, col) => (row === 1 && col === 1 ? { className: 'red-background' } : void 0)
  408. });
  409. $(getCell(0, 0)).simulate('mousedown');
  410. $(getCell(4, 4)).simulate('mouseover');
  411. $(getCell(4, 4)).simulate('mouseup');
  412. expect(window.getComputedStyle(getCell(1, 1))['background-color']).toBe('rgb(255, 0, 0)');
  413. });
  414. it('should select the entire column after column header is clicked (in fixed rows/cols corner)', () => {
  415. handsontable({
  416. width: 200,
  417. height: 100,
  418. startRows: 10,
  419. startCols: 5,
  420. colHeaders: true,
  421. rowHeaders: true,
  422. fixedRowsTop: 2,
  423. fixedColumnsLeft: 2
  424. });
  425. spec().$container.find('.ht_master thead th:eq(1)').simulate('mousedown');
  426. expect(getSelected()).toEqual([[0, 0, 9, 0]]);
  427. expect(`
  428. | ║ * : | : : |
  429. |===:===:===:===:===:===|
  430. | - ║ A : | : : |
  431. | - ║ 0 : | : : |
  432. |---:---:---:---:---:---|
  433. | - ║ 0 : | : : |
  434. | - ║ 0 : | : : |
  435. | - ║ 0 : | : : |
  436. | - ║ 0 : | : : |
  437. | - ║ 0 : | : : |
  438. | - ║ 0 : | : : |
  439. | - ║ 0 : | : : |
  440. | - ║ 0 : | : : |
  441. `).toBeMatchToSelectionPattern();
  442. });
  443. it('should select the entire fixed column after column header is clicked, after scroll horizontally', () => {
  444. const hot = handsontable({
  445. width: 200,
  446. height: 100,
  447. startRows: 10,
  448. startCols: 10,
  449. colHeaders: true,
  450. rowHeaders: true,
  451. fixedColumnsLeft: 2
  452. });
  453. hot.render();
  454. hot.scrollViewportTo(void 0, hot.countCols() - 1);
  455. spec().$container.find('.ht_master thead th:eq(2)').simulate('mousedown');
  456. spec().$container.find('.ht_master thead th:eq(2)').simulate('mouseup');
  457. expect(getSelected()).toEqual([[0, 1, 9, 1]]);
  458. expect(`
  459. | ║ : * | : : : : : : : |
  460. |===:===:===:===:===:===:===:===:===:===:===|
  461. | - ║ : A | : : : : : : : |
  462. | - ║ : 0 | : : : : : : : |
  463. | - ║ : 0 | : : : : : : : |
  464. | - ║ : 0 | : : : : : : : |
  465. | - ║ : 0 | : : : : : : : |
  466. | - ║ : 0 | : : : : : : : |
  467. `).toBeMatchToSelectionPattern();
  468. });
  469. it('should scroll viewport after partially visible column\'s header is clicked, without vertical scroll manipulation', () => {
  470. const hot = handsontable({
  471. width: 200,
  472. height: 100,
  473. startRows: 40,
  474. startCols: 40,
  475. colWidths: 73,
  476. colHeaders: true,
  477. rowHeaders: true,
  478. });
  479. const mainHolder = hot.view.wt.wtTable.holder;
  480. mainHolder.scrollTop = 200;
  481. const firstLastVisibleColumn = hot.view.wt.wtTable.getLastVisibleColumn();
  482. const headerElement = hot.view.wt.wtTable.getColumnHeader(firstLastVisibleColumn + 1);
  483. $(headerElement).simulate('mousedown');
  484. expect(hot.view.wt.wtTable.getLastVisibleColumn()).toBe(firstLastVisibleColumn + 1);
  485. expect(mainHolder.scrollTop).toBe(200);
  486. });
  487. it('should set the selection end to the first visible row, when dragging the selection from a cell to a column header', async() => {
  488. const hot = handsontable({
  489. width: 200,
  490. height: 200,
  491. startRows: 20,
  492. startCols: 20,
  493. colHeaders: true,
  494. rowHeaders: true
  495. });
  496. hot.scrollViewportTo(10, 10);
  497. hot.render();
  498. await sleep(30);
  499. $(getCell(12, 11)).simulate('mousedown');
  500. spec().$container.find('.ht_clone_top thead th:eq(2)').simulate('mouseover');
  501. await sleep(30);
  502. expect(getSelected()).toEqual([[12, 11, 10, 11]]);
  503. });
  504. it('should render selection borders with set proper z-indexes', () => {
  505. const hot = handsontable({
  506. width: 200,
  507. height: 200,
  508. startRows: 20,
  509. startCols: 20,
  510. colHeaders: true,
  511. rowHeaders: true
  512. });
  513. hot.selectCell(1, 1, 2, 2);
  514. expect(Handsontable.dom.getComputedStyle(hot.rootElement.querySelector('.ht_master .htBorders .current')).zIndex).toBe('10');
  515. expect(Handsontable.dom.getComputedStyle(hot.rootElement.querySelector('.ht_master .htBorders .area')).zIndex).toBe('8');
  516. });
  517. it('should set the selection end to the first visible column, when dragging the selection from a cell to a row header', async() => {
  518. const hot = handsontable({
  519. width: 200,
  520. height: 200,
  521. startRows: 20,
  522. startCols: 20,
  523. colHeaders: true,
  524. rowHeaders: true
  525. });
  526. hot.scrollViewportTo(10, 10);
  527. hot.render();
  528. await sleep(30);
  529. $(getCell(12, 11)).simulate('mousedown');
  530. spec().$container.find('.ht_clone_left tbody th:eq(12)').simulate('mouseover');
  531. await sleep(30);
  532. expect(getSelected()).toEqual([[12, 11, 12, 10]]);
  533. });
  534. it('should allow to scroll the table when a whole column is selected and table is longer than it\'s container', async() => {
  535. let errCount = 0;
  536. $(window).on('error.selectionTest', () => {
  537. errCount += 1;
  538. });
  539. const onAfterScrollVertically = jasmine.createSpy('onAfterScrollVertically');
  540. const hot = handsontable({
  541. height: 100,
  542. width: 300,
  543. startRows: 100,
  544. startCols: 5,
  545. colHeaders: true,
  546. rowHeaders: true,
  547. afterScrollVertically: onAfterScrollVertically
  548. });
  549. const mainHolder = hot.view.wt.wtTable.holder;
  550. mainHolder.scrollTop = 0;
  551. spec().$container.find('thead tr:eq(0) th:eq(2)').simulate('mousedown');
  552. spec().$container.find('thead tr:eq(0) th:eq(2)').simulate('mouseup');
  553. mainHolder.scrollTop = 120;
  554. await sleep(100);
  555. expect(errCount).toEqual(0); // expect no errors to be thrown
  556. $(window).off('error.selectionTest');
  557. });
  558. it('should scroll to the end of the selection, when selecting cells using the keyboard', () => {
  559. const hot = handsontable({
  560. height: 300,
  561. width: 300,
  562. startRows: 50,
  563. startCols: 50,
  564. colHeaders: true,
  565. rowHeaders: true,
  566. fixedRowsTop: 2,
  567. fixedColumnsLeft: 2
  568. });
  569. const mainHolder = hot.view.wt.wtTable.holder;
  570. mainHolder.scrollTop = 100;
  571. selectCell(1, 3);
  572. keyDownUp('arrow_down');
  573. expect(mainHolder.scrollTop).toEqual(0);
  574. mainHolder.scrollTop = 100;
  575. selectCell(1, 3);
  576. keyDownUp('shift+arrow_down');
  577. expect(mainHolder.scrollTop).toEqual(0);
  578. mainHolder.scrollLeft = 100;
  579. selectCell(3, 1);
  580. keyDownUp('arrow_right');
  581. expect(mainHolder.scrollLeft).toEqual(0);
  582. mainHolder.scrollLeft = 100;
  583. selectCell(3, 1);
  584. keyDownUp('shift+arrow_right');
  585. expect(mainHolder.scrollLeft).toEqual(0);
  586. const lastVisibleColumn = hot.view.wt.wtTable.getLastVisibleColumn();
  587. selectCell(3, lastVisibleColumn);
  588. keyDownUp('arrow_right');
  589. expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 1);
  590. keyDownUp('arrow_right');
  591. expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 2);
  592. keyDownUp('shift+arrow_right');
  593. expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 3);
  594. const lastVisibleRow = hot.view.wt.wtTable.getLastVisibleRow();
  595. selectCell(lastVisibleRow, 3);
  596. keyDownUp('arrow_down');
  597. expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 1);
  598. keyDownUp('arrow_down');
  599. expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 2);
  600. keyDownUp('shift+arrow_down');
  601. expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 3);
  602. });
  603. it('should scroll to the last selected row or column of the selection, when user uses the keyboard', () => {
  604. const hot = handsontable({
  605. height: 300,
  606. width: 300,
  607. startRows: 50,
  608. startCols: 50,
  609. colHeaders: true,
  610. rowHeaders: true,
  611. fixedRowsTop: 2,
  612. fixedColumnsLeft: 2
  613. });
  614. const mainHolder = hot.view.wt.wtTable.holder;
  615. const lastVisibleColumn = hot.view.wt.wtTable.getLastVisibleColumn();
  616. const lastVisibleRow = hot.view.wt.wtTable.getLastVisibleRow();
  617. const rowHeader = hot.view.wt.wtTable.getRowHeader(lastVisibleRow);
  618. const columnHeader = hot.view.wt.wtTable.getColumnHeader(lastVisibleColumn);
  619. $(columnHeader).simulate('mousedown');
  620. $(columnHeader).simulate('mouseup');
  621. keyDownUp('shift+arrow_right');
  622. expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 1);
  623. keyDownUp('shift+arrow_right');
  624. expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 2);
  625. keyDownUp('shift+arrow_right');
  626. expect(hot.view.wt.wtTable.getLastVisibleColumn()).toEqual(lastVisibleColumn + 3);
  627. const scrollLeft = mainHolder.scrollLeft;
  628. expect(scrollLeft).toBeGreaterThan(0);
  629. expect(mainHolder.scrollTop).toBe(0);
  630. $(rowHeader).simulate('mousedown');
  631. $(rowHeader).simulate('mouseup');
  632. keyDownUp('shift+arrow_down');
  633. expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 1);
  634. keyDownUp('shift+arrow_down');
  635. expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 2);
  636. keyDownUp('shift+arrow_down');
  637. expect(hot.view.wt.wtTable.getLastVisibleRow()).toEqual(lastVisibleRow + 3);
  638. expect(mainHolder.scrollLeft).toBe(scrollLeft);
  639. expect(mainHolder.scrollTop).toBeGreaterThan(0);
  640. });
  641. it('should select the entire row after row header is clicked', () => {
  642. handsontable({
  643. startRows: 5,
  644. startCols: 5,
  645. colHeaders: true,
  646. rowHeaders: true
  647. });
  648. spec().$container.find('tr:eq(2) th:eq(0)').simulate('mousedown');
  649. expect(getSelected()).toEqual([[1, 0, 1, 4]]);
  650. expect(`
  651. | ║ - : - : - : - : - |
  652. |===:===:===:===:===:===|
  653. | ║ : : : : |
  654. | * ║ A : 0 : 0 : 0 : 0 |
  655. | ║ : : : : |
  656. | ║ : : : : |
  657. | ║ : : : : |
  658. `).toBeMatchToSelectionPattern();
  659. });
  660. it('should scroll viewport after partially visible row\'s header is clicked, without horizontal scroll manipulation', () => {
  661. const hot = handsontable({
  662. width: 200,
  663. height: 100,
  664. startRows: 40,
  665. startCols: 40,
  666. rowHeights: 27,
  667. colHeaders: true,
  668. rowHeaders: true,
  669. });
  670. const mainHolder = hot.view.wt.wtTable.holder;
  671. mainHolder.scrollLeft = 200;
  672. const firstLastVisibleRow = hot.view.wt.wtTable.getLastVisibleRow();
  673. const headerElement = hot.view.wt.wtTable.getRowHeader(firstLastVisibleRow + 1);
  674. $(headerElement).simulate('mousedown');
  675. expect(hot.view.wt.wtTable.getLastVisibleRow()).toBe(firstLastVisibleRow + 1);
  676. expect(mainHolder.scrollLeft).toBe(200);
  677. });
  678. it('should select the entire row of a partially fixed table after row header is clicked', () => {
  679. handsontable({
  680. startRows: 5,
  681. startCols: 5,
  682. colHeaders: true,
  683. rowHeaders: true,
  684. fixedRowsTop: 2,
  685. fixedColumnsLeft: 2
  686. });
  687. spec().$container.find('tr:eq(2) th:eq(0)').simulate('mousedown');
  688. expect(getSelected()).toEqual([[1, 0, 1, 4]]);
  689. spec().$container.find('tr:eq(3) th:eq(0)').simulate('mousedown');
  690. expect(getSelected()).toEqual([[2, 0, 2, 4]]);
  691. });
  692. it('should select a cell in a newly added row after automatic row adding, triggered by editing a cell in the last row with minSpareRows > 0, ' +
  693. 'unless editing happened within the fixed bottom rows', async() => {
  694. handsontable({
  695. startRows: 5,
  696. startCols: 2,
  697. minSpareRows: 1
  698. });
  699. await sleep(10);
  700. selectCell(4, 0);
  701. keyDownUp('enter');
  702. await sleep(90);
  703. keyDownUp('enter');
  704. await sleep(100);
  705. expect(countRows()).toEqual(6);
  706. expect(getSelected()).toEqual([[5, 0, 5, 0]]);
  707. });
  708. it('should select a cell which one was added automatically by minSpareCols', () => {
  709. handsontable({
  710. data: Handsontable.helper.createSpreadsheetData(1, 5),
  711. minSpareCols: 1,
  712. });
  713. selectCell(0, 5);
  714. keyDownUp('tab');
  715. expect(countCols()).toEqual(7);
  716. expect(getSelected()).toEqual([[0, 6, 0, 6]]);
  717. expect(getDataAtCell(0, 0)).toEqual('A1');
  718. expect(getDataAtCell(0, 1)).toEqual('B1');
  719. expect(getDataAtCell(0, 2)).toEqual('C1');
  720. expect(getDataAtCell(0, 3)).toEqual('D1');
  721. expect(getDataAtCell(0, 4)).toEqual('E1');
  722. expect(getDataAtCell(0, 5)).toBeNull();
  723. expect(getDataAtCell(0, 6)).toBeNull();
  724. });
  725. it('should change selected coords by modifying coords object via `modifyTransformStart` hook', () => {
  726. const hot = handsontable({
  727. startRows: 5,
  728. startCols: 5
  729. });
  730. selectCell(0, 0);
  731. hot.addHook('modifyTransformStart', (coords) => {
  732. coords.col += 1;
  733. coords.row += 1;
  734. });
  735. keyDown('arrow_down');
  736. expect(getSelected()).toEqual([[2, 1, 2, 1]]);
  737. });
  738. it('should change selected coords by modifying coords object via `modifyTransformEnd` hook', () => {
  739. const hot = handsontable({
  740. startRows: 5,
  741. startCols: 5
  742. });
  743. selectCell(0, 0);
  744. hot.addHook('modifyTransformEnd', (coords) => {
  745. coords.col += 2;
  746. coords.row += 1;
  747. });
  748. keyDown('shift+arrow_down');
  749. expect(getSelected()).toEqual([[0, 0, 2, 2]]);
  750. });
  751. it('should indicate is coords is out of bounds via `afterModifyTransformStart` hook', () => {
  752. const spy = jasmine.createSpy();
  753. const hot = handsontable({
  754. startRows: 5,
  755. startCols: 5,
  756. autoWrapCol: false,
  757. autoWrapRow: false
  758. });
  759. hot.addHook('afterModifyTransformStart', spy);
  760. selectCell(2, 0);
  761. keyDownUp('arrow_left');
  762. expect(spy.calls.mostRecent().args[1]).toBe(0);
  763. expect(spy.calls.mostRecent().args[2]).toBe(-1);
  764. spy.calls.reset();
  765. selectCell(2, 4);
  766. keyDownUp('arrow_right');
  767. expect(spy.calls.mostRecent().args[1]).toBe(0);
  768. expect(spy.calls.mostRecent().args[2]).toBe(1);
  769. spy.calls.reset();
  770. selectCell(4, 2);
  771. keyDownUp('arrow_down');
  772. expect(spy.calls.mostRecent().args[1]).toBe(1);
  773. expect(spy.calls.mostRecent().args[2]).toBe(0);
  774. spy.calls.reset();
  775. selectCell(0, 2);
  776. keyDownUp('arrow_up');
  777. expect(spy.calls.mostRecent().args[1]).toBe(-1);
  778. expect(spy.calls.mostRecent().args[2]).toBe(0);
  779. });
  780. it('should indicate is coords is out of bounds via `afterModifyTransformEnd` hook', () => {
  781. const spy = jasmine.createSpy();
  782. const hot = handsontable({
  783. startRows: 5,
  784. startCols: 5
  785. });
  786. hot.addHook('afterModifyTransformEnd', spy);
  787. selectCell(2, 0);
  788. keyDownUp('shift+arrow_left');
  789. expect(spy.calls.mostRecent().args[1]).toBe(0);
  790. expect(spy.calls.mostRecent().args[2]).toBe(-1);
  791. spy.calls.reset();
  792. selectCell(2, 4);
  793. keyDownUp('shift+arrow_right');
  794. expect(spy.calls.mostRecent().args[1]).toBe(0);
  795. expect(spy.calls.mostRecent().args[2]).toBe(1);
  796. spy.calls.reset();
  797. selectCell(4, 2);
  798. keyDownUp('shift+arrow_down');
  799. expect(spy.calls.mostRecent().args[1]).toBe(1);
  800. expect(spy.calls.mostRecent().args[2]).toBe(0);
  801. spy.calls.reset();
  802. selectCell(0, 2);
  803. keyDownUp('shift+arrow_up');
  804. expect(spy.calls.mostRecent().args[1]).toBe(-1);
  805. expect(spy.calls.mostRecent().args[2]).toBe(0);
  806. });
  807. it('should change selection after left mouse button on one of selected cell', () => {
  808. const hot = handsontable({
  809. startRows: 5,
  810. startCols: 5
  811. });
  812. const cells = $('.ht_master.handsontable td');
  813. cells.eq(6).simulate('mousedown');
  814. cells.eq(18).simulate('mouseover');
  815. cells.eq(18).simulate('mouseup');
  816. expect(hot.getSelected()).toEqual([[1, 1, 3, 3]]);
  817. cells.eq(16).simulate('mousedown');
  818. cells.eq(16).simulate('mouseup');
  819. expect(hot.getSelected()).toEqual([[3, 1, 3, 1]]);
  820. });
  821. it('should select the first row after corner header is clicked', () => {
  822. handsontable({
  823. startRows: 5,
  824. startCols: 5,
  825. colHeaders: true,
  826. rowHeaders: true
  827. });
  828. spec().$container.find('thead').find('th').eq(0).simulate('mousedown');
  829. expect(getSelected()).toEqual([[0, 0, 0, 0]]);
  830. expect(`
  831. | ║ - : : : : |
  832. |===:===:===:===:===:===|
  833. | - ║ # : : : : |
  834. | ║ : : : : |
  835. | ║ : : : : |
  836. | ║ : : : : |
  837. | ║ : : : : |
  838. `).toBeMatchToSelectionPattern();
  839. });
  840. it('should redraw selection when option `colHeaders` is set and user scrolled', async() => {
  841. const hot = handsontable({
  842. startRows: 20,
  843. startCols: 20,
  844. colHeaders: true,
  845. rowHeaders: true,
  846. width: 400,
  847. height: 200
  848. });
  849. let cellVerticalPosition;
  850. const borderOffsetInPixels = 1;
  851. let topBorder;
  852. selectCell(5, 5);
  853. hot.view.wt.wtOverlays.topOverlay.scrollTo(2);
  854. await sleep(100);
  855. cellVerticalPosition = hot.getCell(5, 5).offsetTop;
  856. topBorder = $('.wtBorder.current')[0];
  857. expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
  858. hot.view.wt.wtOverlays.topOverlay.scrollTo(0);
  859. await sleep(100);
  860. cellVerticalPosition = hot.getCell(5, 5).offsetTop;
  861. topBorder = $('.wtBorder.current')[0];
  862. expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
  863. });
  864. it('should redraw selection on `leftOverlay` when options `colHeaders` and `fixedColumnsLeft` are set, and user scrolled', async() => {
  865. const hot = handsontable({
  866. fixedColumnsLeft: 2,
  867. startRows: 20,
  868. startCols: 20,
  869. colHeaders: true,
  870. rowHeaders: true,
  871. width: 400,
  872. height: 200
  873. });
  874. let cellVerticalPosition;
  875. const borderOffsetInPixels = 1;
  876. let topBorder;
  877. selectCell(1, 0);
  878. hot.view.wt.wtOverlays.topOverlay.scrollTo(5);
  879. await sleep(100);
  880. cellVerticalPosition = hot.getCell(1, 0).offsetTop;
  881. topBorder = $('.wtBorder.current')[0];
  882. expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
  883. hot.view.wt.wtOverlays.topOverlay.scrollTo(0);
  884. await sleep(100);
  885. cellVerticalPosition = hot.getCell(1, 0).offsetTop;
  886. topBorder = $('.wtBorder.current')[0];
  887. expect(topBorder.offsetTop).toEqual(cellVerticalPosition - borderOffsetInPixels);
  888. });
  889. describe('multiple selection mode', () => {
  890. it('should select cells by using two layers when CTRL key is pressed (default mode of the selectionMode option)', () => {
  891. handsontable({
  892. startRows: 8,
  893. startCols: 10
  894. });
  895. $(getCell(1, 1)).simulate('mousedown');
  896. $(getCell(4, 4)).simulate('mouseover');
  897. $(getCell(4, 4)).simulate('mouseup');
  898. expect(getSelected()).toEqual([[1, 1, 4, 4]]);
  899. keyDown('ctrl');
  900. $(getCell(3, 3)).simulate('mousedown');
  901. $(getCell(5, 6)).simulate('mouseover');
  902. $(getCell(5, 6)).simulate('mouseup');
  903. expect(getSelected()).toEqual([[1, 1, 4, 4], [3, 3, 5, 6]]);
  904. });
  905. it('should be disallowed to select non-consecutive cells when selectionMode is set as `single`', () => {
  906. handsontable({
  907. startRows: 8,
  908. startCols: 10,
  909. selectionMode: 'single',
  910. });
  911. $(getCell(1, 1)).simulate('mousedown');
  912. $(getCell(4, 4)).simulate('mouseover');
  913. $(getCell(4, 4)).simulate('mouseup');
  914. expect(getSelected()).toEqual([[1, 1, 1, 1]]);
  915. keyDown('ctrl');
  916. $(getCell(3, 3)).simulate('mousedown');
  917. $(getCell(5, 6)).simulate('mouseover');
  918. $(getCell(5, 6)).simulate('mouseup');
  919. expect(getSelected()).toEqual([[3, 3, 3, 3]]);
  920. });
  921. it('should be allowed to select consecutive cells when selectionMode is set as `range`', () => {
  922. handsontable({
  923. startRows: 8,
  924. startCols: 10,
  925. selectionMode: 'range',
  926. });
  927. $(getCell(1, 1)).simulate('mousedown');
  928. $(getCell(4, 4)).simulate('mouseover');
  929. $(getCell(4, 4)).simulate('mouseup');
  930. expect(getSelected()).toEqual([[1, 1, 4, 4]]);
  931. $(getCell(3, 3)).simulate('mousedown');
  932. $(getCell(5, 6)).simulate('mouseover');
  933. $(getCell(5, 6)).simulate('mouseup');
  934. expect(getSelected()).toEqual([[3, 3, 5, 6]]);
  935. });
  936. it('should be disallowed to select non-consecutive cells when selectionMode is set as `range`', () => {
  937. handsontable({
  938. startRows: 8,
  939. startCols: 10,
  940. selectionMode: 'range',
  941. });
  942. $(getCell(1, 1)).simulate('mousedown');
  943. $(getCell(4, 4)).simulate('mouseover');
  944. $(getCell(4, 4)).simulate('mouseup');
  945. expect(getSelected()).toEqual([[1, 1, 4, 4]]);
  946. keyDown('ctrl');
  947. $(getCell(3, 3)).simulate('mousedown');
  948. $(getCell(5, 6)).simulate('mouseover');
  949. $(getCell(5, 6)).simulate('mouseup');
  950. expect(getSelected()).toEqual([[3, 3, 5, 6]]);
  951. });
  952. it('should properly colorize selection layers including layer intersections', () => {
  953. handsontable({
  954. startRows: 21,
  955. startCols: 30,
  956. selectionMode: 'multiple',
  957. colHeaders: true,
  958. rowHeaders: true,
  959. });
  960. $(getCell(0, 0)).simulate('mousedown');
  961. $(getCell(20, 15)).simulate('mouseover');
  962. $(getCell(20, 15)).simulate('mouseup');
  963. keyDown('ctrl');
  964. $(getCell(1, 1)).simulate('mousedown');
  965. $(getCell(19, 16)).simulate('mouseover');
  966. $(getCell(19, 16)).simulate('mouseup');
  967. $(getCell(2, 2)).simulate('mousedown');
  968. $(getCell(18, 17)).simulate('mouseover');
  969. $(getCell(18, 17)).simulate('mouseup');
  970. $(getCell(3, 3)).simulate('mousedown');
  971. $(getCell(17, 18)).simulate('mouseover');
  972. $(getCell(17, 18)).simulate('mouseup');
  973. $(getCell(4, 4)).simulate('mousedown');
  974. $(getCell(16, 19)).simulate('mouseover');
  975. $(getCell(16, 19)).simulate('mouseup');
  976. $(getCell(5, 5)).simulate('mousedown');
  977. $(getCell(15, 20)).simulate('mouseover');
  978. $(getCell(15, 20)).simulate('mouseup');
  979. $(getCell(6, 6)).simulate('mousedown');
  980. $(getCell(14, 21)).simulate('mouseover');
  981. $(getCell(14, 21)).simulate('mouseup');
  982. $(getCell(7, 7)).simulate('mousedown');
  983. $(getCell(13, 22)).simulate('mouseover');
  984. $(getCell(13, 22)).simulate('mouseup');
  985. $(getCell(8, 8)).simulate('mousedown');
  986. $(getCell(12, 23)).simulate('mouseover');
  987. $(getCell(12, 23)).simulate('mouseup');
  988. $(getCell(9, 9)).simulate('mousedown');
  989. $(getCell(11, 24)).simulate('mouseover');
  990. $(getCell(11, 24)).simulate('mouseup');
  991. $(getCell(10, 10)).simulate('mousedown');
  992. $(getCell(10, 25)).simulate('mouseover');
  993. $(getCell(10, 25)).simulate('mouseup');
  994. expect(`
  995. | ║ - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : - : : : : |
  996. |===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===:===|
  997. | - ║ 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : : : : : : : : : : : : : : |
  998. | - ║ 0 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 0 : : : : : : : : : : : : : |
  999. | - ║ 0 : 1 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 1 : 0 : : : : : : : : : : : : |
  1000. | - ║ 0 : 1 : 2 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 2 : 1 : 0 : : : : : : : : : : : |
  1001. | - ║ 0 : 1 : 2 : 3 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 3 : 2 : 1 : 0 : : : : : : : : : : |
  1002. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : : : : |
  1003. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : : : |
  1004. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : : |
  1005. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : |
  1006. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : |
  1007. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 7 : 7 : H : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : |
  1008. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : |
  1009. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : |
  1010. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 7 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : : |
  1011. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 6 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : : : |
  1012. | - ║ 0 : 1 : 2 : 3 : 4 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 5 : 4 : 3 : 2 : 1 : 0 : : : : : : : : : |
  1013. | - ║ 0 : 1 : 2 : 3 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 4 : 3 : 2 : 1 : 0 : : : : : : : : : : |
  1014. | - ║ 0 : 1 : 2 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 3 : 2 : 1 : 0 : : : : : : : : : : : |
  1015. | - ║ 0 : 1 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 2 : 1 : 0 : : : : : : : : : : : : |
  1016. | - ║ 0 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 1 : 0 : : : : : : : : : : : : : |
  1017. | - ║ 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : 0 : : : : : : : : : : : : : : |
  1018. `).toBeMatchToSelectionPattern();
  1019. });
  1020. it('should call afterSelection and afterSelectionEnd hooks with proper arguments', () => {
  1021. const hooks = jasmine.createSpyObj('hooks', ['afterSelection', 'afterSelectionEnd']);
  1022. handsontable({
  1023. startRows: 21,
  1024. startCols: 30,
  1025. selectionMode: 'multiple',
  1026. afterSelection: hooks.afterSelection,
  1027. afterSelectionEnd: hooks.afterSelectionEnd,
  1028. });
  1029. $(getCell(0, 0)).simulate('mousedown');
  1030. $(getCell(20, 15)).simulate('mouseover');
  1031. $(getCell(20, 15)).simulate('mouseup');
  1032. expect(hooks.afterSelection.calls.count()).toBe(2);
  1033. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([0, 0, 0, 0, jasmine.any(Object), 0]);
  1034. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([0, 0, 20, 15, jasmine.any(Object), 0]);
  1035. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1036. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([0, 0, 20, 15, 0, void 0]);
  1037. keyDown('ctrl');
  1038. hooks.afterSelection.calls.reset();
  1039. hooks.afterSelectionEnd.calls.reset();
  1040. $(getCell(1, 1)).simulate('mousedown');
  1041. $(getCell(19, 16)).simulate('mouseover');
  1042. $(getCell(19, 16)).simulate('mouseup');
  1043. expect(hooks.afterSelection.calls.count()).toBe(2);
  1044. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([1, 1, 1, 1, jasmine.any(Object), 1]);
  1045. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([1, 1, 19, 16, jasmine.any(Object), 1]);
  1046. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1047. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([1, 1, 19, 16, 1, void 0]);
  1048. hooks.afterSelection.calls.reset();
  1049. hooks.afterSelectionEnd.calls.reset();
  1050. $(getCell(2, 2)).simulate('mousedown');
  1051. $(getCell(18, 17)).simulate('mouseover');
  1052. $(getCell(18, 17)).simulate('mouseup');
  1053. expect(hooks.afterSelection.calls.count()).toBe(2);
  1054. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([2, 2, 2, 2, jasmine.any(Object), 2]);
  1055. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([2, 2, 18, 17, jasmine.any(Object), 2]);
  1056. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1057. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([2, 2, 18, 17, 2, void 0]);
  1058. hooks.afterSelection.calls.reset();
  1059. hooks.afterSelectionEnd.calls.reset();
  1060. $(getCell(3, 3)).simulate('mousedown');
  1061. $(getCell(17, 18)).simulate('mouseover');
  1062. $(getCell(17, 18)).simulate('mouseup');
  1063. expect(hooks.afterSelection.calls.count()).toBe(2);
  1064. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([3, 3, 3, 3, jasmine.any(Object), 3]);
  1065. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([3, 3, 17, 18, jasmine.any(Object), 3]);
  1066. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1067. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([3, 3, 17, 18, 3, void 0]);
  1068. hooks.afterSelection.calls.reset();
  1069. hooks.afterSelectionEnd.calls.reset();
  1070. $(getCell(4, 4)).simulate('mousedown');
  1071. $(getCell(16, 19)).simulate('mouseover');
  1072. $(getCell(16, 19)).simulate('mouseup');
  1073. expect(hooks.afterSelection.calls.count()).toBe(2);
  1074. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([4, 4, 4, 4, jasmine.any(Object), 4]);
  1075. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([4, 4, 16, 19, jasmine.any(Object), 4]);
  1076. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1077. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([4, 4, 16, 19, 4, void 0]);
  1078. hooks.afterSelection.calls.reset();
  1079. hooks.afterSelectionEnd.calls.reset();
  1080. $(getCell(5, 5)).simulate('mousedown');
  1081. $(getCell(15, 20)).simulate('mouseover');
  1082. $(getCell(15, 20)).simulate('mouseup');
  1083. expect(hooks.afterSelection.calls.count()).toBe(2);
  1084. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([5, 5, 5, 5, jasmine.any(Object), 5]);
  1085. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([5, 5, 15, 20, jasmine.any(Object), 5]);
  1086. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1087. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([5, 5, 15, 20, 5, void 0]);
  1088. hooks.afterSelection.calls.reset();
  1089. hooks.afterSelectionEnd.calls.reset();
  1090. $(getCell(6, 6)).simulate('mousedown');
  1091. $(getCell(14, 21)).simulate('mouseover');
  1092. $(getCell(14, 21)).simulate('mouseup');
  1093. expect(hooks.afterSelection.calls.count()).toBe(2);
  1094. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([6, 6, 6, 6, jasmine.any(Object), 6]);
  1095. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([6, 6, 14, 21, jasmine.any(Object), 6]);
  1096. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1097. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([6, 6, 14, 21, 6, void 0]);
  1098. hooks.afterSelection.calls.reset();
  1099. hooks.afterSelectionEnd.calls.reset();
  1100. $(getCell(7, 7)).simulate('mousedown');
  1101. $(getCell(13, 22)).simulate('mouseover');
  1102. $(getCell(13, 22)).simulate('mouseup');
  1103. expect(hooks.afterSelection.calls.count()).toBe(2);
  1104. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([7, 7, 7, 7, jasmine.any(Object), 7]);
  1105. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([7, 7, 13, 22, jasmine.any(Object), 7]);
  1106. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1107. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([7, 7, 13, 22, 7, void 0]);
  1108. hooks.afterSelection.calls.reset();
  1109. hooks.afterSelectionEnd.calls.reset();
  1110. $(getCell(8, 8)).simulate('mousedown');
  1111. $(getCell(12, 23)).simulate('mouseover');
  1112. $(getCell(12, 23)).simulate('mouseup');
  1113. expect(hooks.afterSelection.calls.count()).toBe(2);
  1114. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([8, 8, 8, 8, jasmine.any(Object), 8]);
  1115. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([8, 8, 12, 23, jasmine.any(Object), 8]);
  1116. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1117. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([8, 8, 12, 23, 8, void 0]);
  1118. hooks.afterSelection.calls.reset();
  1119. hooks.afterSelectionEnd.calls.reset();
  1120. $(getCell(9, 9)).simulate('mousedown');
  1121. $(getCell(11, 24)).simulate('mouseover');
  1122. $(getCell(11, 24)).simulate('mouseup');
  1123. expect(hooks.afterSelection.calls.count()).toBe(2);
  1124. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([9, 9, 9, 9, jasmine.any(Object), 9]);
  1125. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([9, 9, 11, 24, jasmine.any(Object), 9]);
  1126. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1127. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([9, 9, 11, 24, 9, void 0]);
  1128. hooks.afterSelection.calls.reset();
  1129. hooks.afterSelectionEnd.calls.reset();
  1130. $(getCell(10, 10)).simulate('mousedown');
  1131. $(getCell(10, 25)).simulate('mouseover');
  1132. $(getCell(10, 25)).simulate('mouseup');
  1133. expect(hooks.afterSelection.calls.count()).toBe(2);
  1134. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([10, 10, 10, 10, jasmine.any(Object), 10]);
  1135. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([10, 10, 10, 25, jasmine.any(Object), 10]);
  1136. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1137. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([10, 10, 10, 25, 10, void 0]);
  1138. });
  1139. it('should call afterSelectionByProp and afterSelectionEndByProp hooks with proper arguments', () => {
  1140. const hooks = jasmine.createSpyObj('hooks', ['afterSelection', 'afterSelectionEnd']);
  1141. handsontable({
  1142. data: Handsontable.helper.createSpreadsheetObjectData(21, 30),
  1143. selectionMode: 'multiple',
  1144. afterSelectionByProp: hooks.afterSelection,
  1145. afterSelectionEndByProp: hooks.afterSelectionEnd,
  1146. });
  1147. $(getCell(0, 0)).simulate('mousedown');
  1148. $(getCell(20, 15)).simulate('mouseover');
  1149. $(getCell(20, 15)).simulate('mouseup');
  1150. expect(hooks.afterSelection.calls.count()).toBe(2);
  1151. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([0, 'prop0', 0, 'prop0', jasmine.any(Object), 0]);
  1152. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([0, 'prop0', 20, 'prop15', jasmine.any(Object), 0]);
  1153. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1154. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([0, 'prop0', 20, 'prop15', 0, void 0]);
  1155. keyDown('ctrl');
  1156. hooks.afterSelection.calls.reset();
  1157. hooks.afterSelectionEnd.calls.reset();
  1158. $(getCell(1, 1)).simulate('mousedown');
  1159. $(getCell(19, 16)).simulate('mouseover');
  1160. $(getCell(19, 16)).simulate('mouseup');
  1161. expect(hooks.afterSelection.calls.count()).toBe(2);
  1162. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([1, 'prop1', 1, 'prop1', jasmine.any(Object), 1]);
  1163. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([1, 'prop1', 19, 'prop16', jasmine.any(Object), 1]);
  1164. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1165. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([1, 'prop1', 19, 'prop16', 1, void 0]);
  1166. hooks.afterSelection.calls.reset();
  1167. hooks.afterSelectionEnd.calls.reset();
  1168. $(getCell(2, 2)).simulate('mousedown');
  1169. $(getCell(18, 17)).simulate('mouseover');
  1170. $(getCell(18, 17)).simulate('mouseup');
  1171. expect(hooks.afterSelection.calls.count()).toBe(2);
  1172. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([2, 'prop2', 2, 'prop2', jasmine.any(Object), 2]);
  1173. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([2, 'prop2', 18, 'prop17', jasmine.any(Object), 2]);
  1174. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1175. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([2, 'prop2', 18, 'prop17', 2, void 0]);
  1176. hooks.afterSelection.calls.reset();
  1177. hooks.afterSelectionEnd.calls.reset();
  1178. $(getCell(3, 3)).simulate('mousedown');
  1179. $(getCell(17, 18)).simulate('mouseover');
  1180. $(getCell(17, 18)).simulate('mouseup');
  1181. expect(hooks.afterSelection.calls.count()).toBe(2);
  1182. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([3, 'prop3', 3, 'prop3', jasmine.any(Object), 3]);
  1183. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([3, 'prop3', 17, 'prop18', jasmine.any(Object), 3]);
  1184. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1185. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([3, 'prop3', 17, 'prop18', 3, void 0]);
  1186. hooks.afterSelection.calls.reset();
  1187. hooks.afterSelectionEnd.calls.reset();
  1188. $(getCell(4, 4)).simulate('mousedown');
  1189. $(getCell(16, 19)).simulate('mouseover');
  1190. $(getCell(16, 19)).simulate('mouseup');
  1191. expect(hooks.afterSelection.calls.count()).toBe(2);
  1192. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([4, 'prop4', 4, 'prop4', jasmine.any(Object), 4]);
  1193. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([4, 'prop4', 16, 'prop19', jasmine.any(Object), 4]);
  1194. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1195. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([4, 'prop4', 16, 'prop19', 4, void 0]);
  1196. hooks.afterSelection.calls.reset();
  1197. hooks.afterSelectionEnd.calls.reset();
  1198. $(getCell(5, 5)).simulate('mousedown');
  1199. $(getCell(15, 20)).simulate('mouseover');
  1200. $(getCell(15, 20)).simulate('mouseup');
  1201. expect(hooks.afterSelection.calls.count()).toBe(2);
  1202. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([5, 'prop5', 5, 'prop5', jasmine.any(Object), 5]);
  1203. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([5, 'prop5', 15, 'prop20', jasmine.any(Object), 5]);
  1204. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1205. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([5, 'prop5', 15, 'prop20', 5, void 0]);
  1206. hooks.afterSelection.calls.reset();
  1207. hooks.afterSelectionEnd.calls.reset();
  1208. $(getCell(6, 6)).simulate('mousedown');
  1209. $(getCell(14, 21)).simulate('mouseover');
  1210. $(getCell(14, 21)).simulate('mouseup');
  1211. expect(hooks.afterSelection.calls.count()).toBe(2);
  1212. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([6, 'prop6', 6, 'prop6', jasmine.any(Object), 6]);
  1213. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([6, 'prop6', 14, 'prop21', jasmine.any(Object), 6]);
  1214. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1215. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([6, 'prop6', 14, 'prop21', 6, void 0]);
  1216. hooks.afterSelection.calls.reset();
  1217. hooks.afterSelectionEnd.calls.reset();
  1218. $(getCell(7, 7)).simulate('mousedown');
  1219. $(getCell(13, 22)).simulate('mouseover');
  1220. $(getCell(13, 22)).simulate('mouseup');
  1221. expect(hooks.afterSelection.calls.count()).toBe(2);
  1222. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([7, 'prop7', 7, 'prop7', jasmine.any(Object), 7]);
  1223. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([7, 'prop7', 13, 'prop22', jasmine.any(Object), 7]);
  1224. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1225. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([7, 'prop7', 13, 'prop22', 7, void 0]);
  1226. hooks.afterSelection.calls.reset();
  1227. hooks.afterSelectionEnd.calls.reset();
  1228. $(getCell(8, 8)).simulate('mousedown');
  1229. $(getCell(12, 23)).simulate('mouseover');
  1230. $(getCell(12, 23)).simulate('mouseup');
  1231. expect(hooks.afterSelection.calls.count()).toBe(2);
  1232. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([8, 'prop8', 8, 'prop8', jasmine.any(Object), 8]);
  1233. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([8, 'prop8', 12, 'prop23', jasmine.any(Object), 8]);
  1234. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1235. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([8, 'prop8', 12, 'prop23', 8, void 0]);
  1236. hooks.afterSelection.calls.reset();
  1237. hooks.afterSelectionEnd.calls.reset();
  1238. $(getCell(9, 9)).simulate('mousedown');
  1239. $(getCell(11, 24)).simulate('mouseover');
  1240. $(getCell(11, 24)).simulate('mouseup');
  1241. expect(hooks.afterSelection.calls.count()).toBe(2);
  1242. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([9, 'prop9', 9, 'prop9', jasmine.any(Object), 9]);
  1243. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([9, 'prop9', 11, 'prop24', jasmine.any(Object), 9]);
  1244. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1245. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([9, 'prop9', 11, 'prop24', 9, void 0]);
  1246. hooks.afterSelection.calls.reset();
  1247. hooks.afterSelectionEnd.calls.reset();
  1248. $(getCell(10, 10)).simulate('mousedown');
  1249. $(getCell(10, 25)).simulate('mouseover');
  1250. $(getCell(10, 25)).simulate('mouseup');
  1251. expect(hooks.afterSelection.calls.count()).toBe(2);
  1252. expect(hooks.afterSelection.calls.argsFor(0)).toEqual([10, 'prop10', 10, 'prop10', jasmine.any(Object), 10]);
  1253. expect(hooks.afterSelection.calls.argsFor(1)).toEqual([10, 'prop10', 10, 'prop25', jasmine.any(Object), 10]);
  1254. expect(hooks.afterSelectionEnd.calls.count()).toBe(1);
  1255. expect(hooks.afterSelectionEnd.calls.argsFor(0)).toEqual([10, 'prop10', 10, 'prop25', 10, void 0]);
  1256. });
  1257. });
  1258. });