(function() {
describe('Setup', function() {
it('should not allow duplicate initialization', function() {
var instance_before, instance_after, test;
test = setup_test('', {});
instance_before = test.$select[0].selectize;
test.$select.selectize();
instance_after = test.$select[0].selectize;
expect(instance_before).to.be.equal(instance_after);
});
describe('', function() {
it('should complete without exceptions', function() {
var test = setup_test('', {});
});
it('should populate items,options from "dataAttr" if available', function() {
var data = [{val: 'a', lbl: 'Hello'}, {val: 'b', lbl: 'World'}];
var test = setup_test('', {
dataAttr: 'data-hydrate',
valueField: 'val',
labelField: 'lbl'
});
expect(test.selectize.getValue()).to.be.equal('a,b');
assert.deepEqual(test.selectize.items, ['a','b']);
assert.deepEqual(test.selectize.options, {
'a': {val: 'a', lbl: 'Hello', $order: 1},
'b': {val: 'b', lbl: 'World', $order: 2}
});
});
describe('getValue()', function() {
it('should return value as a string', function() {
var test = setup_test('', {delimiter: ','});
expect(test.selectize.getValue()).to.be.a('string');
});
it('should return "" when empty', function() {
var test = setup_test('', {delimiter: ','});
expect(test.selectize.getValue()).to.be.equal('');
});
it('should return proper value when not empty', function() {
var test = setup_test('', {delimiter: ','});
expect(test.selectize.getValue()).to.be.equal('a,b');
});
});
describe('', function() {
it('should propagate original input attributes to the generated input', function() {
var test = setup_test('', {});
expect(test.selectize.$control_input.attr('autocorrect')).to.be.equal('off');
expect(test.selectize.$control_input.attr('autocapitalize')).to.be.equal('none');
});
it('should not add attributes if not present in the original', function() {
var test = setup_test('', {});
expect(test.selectize.$control_input.attr('autocorrect')).to.be.equal(undefined);
expect(test.selectize.$control_input.attr('autocapitalize')).to.be.equal(undefined);
});
});
});
describe('