0bb4eae967cf3c1dec4babb999772e0cd282ff39df5716bb8d1da77707f98455f74eb7e760d0ee0f5880d424e4f527b3c72dc038d540385a7db99b54d3928f 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. describe('PasswordEditor', () => {
  2. var id = 'testContainer';
  3. beforeEach(function() {
  4. this.$container = $(`<div id="${id}" style="width: 300px; height: 300px;"></div>`).appendTo('body');
  5. });
  6. afterEach(function() {
  7. if (this.$container) {
  8. destroy();
  9. this.$container.remove();
  10. }
  11. });
  12. it('should display editor as password field', () => {
  13. handsontable({
  14. data: [
  15. ['Joe'],
  16. ['Timothy'],
  17. ['Margaret'],
  18. ['Jerry']
  19. ],
  20. columns: [
  21. {
  22. editor: Handsontable.editors.PasswordEditor
  23. }
  24. ]
  25. });
  26. selectCell(0, 0);
  27. keyDown('enter');
  28. var editor = $('.handsontableInput');
  29. expect(editor.is(':visible')).toBe(true);
  30. expect(editor.is(':password')).toBe(true);
  31. });
  32. it('should set passwordEditor using \'password\' alias', () => {
  33. handsontable({
  34. data: [
  35. ['Joe'],
  36. ['Timothy'],
  37. ['Margaret'],
  38. ['Jerry']
  39. ],
  40. columns: [
  41. {
  42. editor: 'password'
  43. }
  44. ]
  45. });
  46. selectCell(0, 0);
  47. keyDown('enter');
  48. var editor = $('.handsontableInput');
  49. expect(editor.is(':visible')).toBe(true);
  50. expect(editor.is(':password')).toBe(true);
  51. });
  52. it('should set passwordEditor using column type \'password\' ', () => {
  53. handsontable({
  54. data: [
  55. ['Joe'],
  56. ['Timothy'],
  57. ['Margaret'],
  58. ['Jerry']
  59. ],
  60. columns: [
  61. {
  62. type: 'password'
  63. }
  64. ]
  65. });
  66. selectCell(0, 0);
  67. keyDown('enter');
  68. var editorHolder = $('.handsontableInputHolder');
  69. var editor = editorHolder.find('.handsontableInput');
  70. expect(editorHolder.is(':visible')).toBe(true);
  71. expect(editor.is(':password')).toBe(true);
  72. });
  73. it('should save values typed in passwordEditor', () => {
  74. handsontable({
  75. data: [
  76. ['Joe'],
  77. ['Timothy'],
  78. ['Margaret'],
  79. ['Jerry']
  80. ],
  81. columns: [
  82. {
  83. editor: 'password'
  84. }
  85. ]
  86. });
  87. selectCell(0, 0);
  88. expect(getDataAtCell(0, 0)).toMatch('Joe');
  89. expect(getRenderedValue(0, 0)).toMatch('Joe');
  90. keyDown('enter');
  91. var editorHolder = $('.handsontableInputHolder');
  92. var editor = editorHolder.find('.handsontableInput');
  93. expect(editorHolder.is(':visible')).toBe(true);
  94. editor.val('Edgar');
  95. selectCell(1, 0); // closes editor and saves current value
  96. expect(editorHolder.is(':visible')).toBe(false);
  97. expect(getDataAtCell(0, 0)).toMatch('Edgar');
  98. expect(getRenderedValue(0, 0)).toMatch('Edgar');
  99. });
  100. });