Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$select.select2({maximumSelectionLength: 2, multiple: true});
assert.equal(
$select.val(),
'3',
'Only 1 option should be pulled.'
);
// Try to resolve instance via .data('select2').
var $instance = $select.data('select2');
assert.ok($instance);
assert.ok($instance.options);
// Ensure $select.data('select2') is the same instance
// created by .select2()
assert.equal($instance, Utils.GetData($instance.$element[0],
'select2'));
// Ensure initialized property matches.
assert.equal($instance.options.options.maximumSelectionLength,
2);
});
test('automatically generated option tags have a result id', function (assert) {
var $select = $('#qunit-fixture .single-empty');
var data = new ArrayData($select, arrayOptions);
var container = new MockContainer();
data.bind(container, $('<div></div>'));
data.select({
id: 'default'
});
assert.ok(
Utils.GetData($select.find(':selected')[0], 'data')._resultId,
'<option> default should have a result ID assigned'
);
});
</option>
var container = new MockContainer();
data.bind(container, $('<div></div>'));
assert.equal(
$select.find('option').length,
2,
'Only one more <option> element should be created'
);
data.select({
id: 'default'
});
assert.ok(
Utils.GetData($select.find(':selected')[0], 'data').extra,
'</option><option> default should have new data'
);
data.select({
id: 'One'
});
assert.ok(
Utils.GetData($select.find(':selected')[0], 'data').extra,
'</option><option> One should have new data'
);
});
</option>