| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- describe('PasswordEditor', () => {
- var id = 'testContainer';
- beforeEach(function() {
- this.$container = $(`<div id="${id}" style="width: 300px; height: 300px;"></div>`).appendTo('body');
- });
- afterEach(function() {
- if (this.$container) {
- destroy();
- this.$container.remove();
- }
- });
- it('should display editor as password field', () => {
- handsontable({
- data: [
- ['Joe'],
- ['Timothy'],
- ['Margaret'],
- ['Jerry']
- ],
- columns: [
- {
- editor: Handsontable.editors.PasswordEditor
- }
- ]
- });
- selectCell(0, 0);
- keyDown('enter');
- var editor = $('.handsontableInput');
- expect(editor.is(':visible')).toBe(true);
- expect(editor.is(':password')).toBe(true);
- });
- it('should set passwordEditor using \'password\' alias', () => {
- handsontable({
- data: [
- ['Joe'],
- ['Timothy'],
- ['Margaret'],
- ['Jerry']
- ],
- columns: [
- {
- editor: 'password'
- }
- ]
- });
- selectCell(0, 0);
- keyDown('enter');
- var editor = $('.handsontableInput');
- expect(editor.is(':visible')).toBe(true);
- expect(editor.is(':password')).toBe(true);
- });
- it('should set passwordEditor using column type \'password\' ', () => {
- handsontable({
- data: [
- ['Joe'],
- ['Timothy'],
- ['Margaret'],
- ['Jerry']
- ],
- columns: [
- {
- type: 'password'
- }
- ]
- });
- selectCell(0, 0);
- keyDown('enter');
- var editorHolder = $('.handsontableInputHolder');
- var editor = editorHolder.find('.handsontableInput');
- expect(editorHolder.is(':visible')).toBe(true);
- expect(editor.is(':password')).toBe(true);
- });
- it('should save values typed in passwordEditor', () => {
- handsontable({
- data: [
- ['Joe'],
- ['Timothy'],
- ['Margaret'],
- ['Jerry']
- ],
- columns: [
- {
- editor: 'password'
- }
- ]
- });
- selectCell(0, 0);
- expect(getDataAtCell(0, 0)).toMatch('Joe');
- expect(getRenderedValue(0, 0)).toMatch('Joe');
- keyDown('enter');
- var editorHolder = $('.handsontableInputHolder');
- var editor = editorHolder.find('.handsontableInput');
- expect(editorHolder.is(':visible')).toBe(true);
- editor.val('Edgar');
- selectCell(1, 0); // closes editor and saves current value
- expect(editorHolder.is(':visible')).toBe(false);
- expect(getDataAtCell(0, 0)).toMatch('Edgar');
- expect(getRenderedValue(0, 0)).toMatch('Edgar');
- });
- });
|