Skip to content

Commit

Permalink
add input_autogrow test
Browse files Browse the repository at this point in the history
  • Loading branch information
oyejorge committed Nov 15, 2020
1 parent 0856ce8 commit daf4a8d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/plugins/input_autogrow/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ TomSelect.define('input_autogrow', function(options) {

var test_input = document.createElement('span');
var control = this.control_input;
test_input.style.position = 'absolute';
test_input.style.top = '-99999px';
test_input.style.left = '-99999px';
test_input.style.width = 'auto';
test_input.style.padding = '0';
test_input.style.whiteSpace = 'pre';
test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';

self.wrapper.appendChild(test_input);

Expand Down
22 changes: 22 additions & 0 deletions test/tests/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,25 @@ describe('plugin: change_listener', function() {
});

});


describe('plugin: input_autogrow', function() {

it_n('width of control should change as text changes', function(done) {

let test = setup_test('<input>', {plugins: ['input_autogrow']});

syn.type('a', test.instance.control_input, function() {
let width_orig = test.instance.control_input.clientWidth;

syn.type('a', test.instance.control_input, function() {
let width_now = test.instance.control_input.clientWidth;

expect(width_now).to.be.above(width_orig);
done();
});
});

});

});

0 comments on commit daf4a8d

Please sign in to comment.