This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
calcifer/web/vendor/selectize.js/test/events_dom.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

describe('DOM Events', function() {
describe('"change"', function() {
it('should be triggered once by addItem()', function(done) {
var test = setup_test('<select>', {
valueField: 'value',
labelField: 'value',
options: [
{value: 'a'},
{value: 'b'},
],
items: ['a']
});
var counter = 0;
test.$select.on('change', function() { counter++; });
test.selectize.addItem('b');
window.setTimeout(function() {
expect(counter).to.be.equal(1);
done();
}, 0);
});
it('should be triggered once by removeItem()', function(done) {
var test = setup_test('<select multiple>', {
valueField: 'value',
labelField: 'value',
options: [
{value: 'a'},
{value: 'b'},
],
items: ['a','b']
});
var counter = 0;
test.$select.on('change', function() { counter++; });
test.selectize.removeItem('b');
window.setTimeout(function() {
expect(counter).to.be.equal(1);
done();
}, 0);
});
it('should be triggered once by clear()', function(done) {
var test = setup_test('<select multiple>', {
valueField: 'value',
labelField: 'value',
options: [
{value: 'a'},
{value: 'b'},
],
items: ['a','b']
});
var counter = 0;
test.$select.on('change', function() { counter++; });
test.selectize.clear();
window.setTimeout(function() {
expect(counter).to.be.equal(1);
done();
}, 0);
});
});
});