|
@@ -21,6 +21,21 @@ var arrayOptions = new Options({
|
|
|
]
|
|
|
});
|
|
|
|
|
|
+var extraOptions = new Options ({
|
|
|
+ data: [
|
|
|
+ {
|
|
|
+ id: 'default',
|
|
|
+ text: 'Default',
|
|
|
+ extra: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 'One',
|
|
|
+ text: 'One',
|
|
|
+ extra: true
|
|
|
+ }
|
|
|
+ ]
|
|
|
+});
|
|
|
+
|
|
|
var nestedOptions = new Options({
|
|
|
data: [
|
|
|
{
|
|
@@ -206,6 +221,36 @@ test('option tags are automatically generated', function (assert) {
|
|
|
);
|
|
|
});
|
|
|
|
|
|
+test('option tags can receive new data', function(assert) {
|
|
|
+ var $select = $('#qunit-fixture .single');
|
|
|
+
|
|
|
+ var data = new ArrayData($select, extraOptions);
|
|
|
+
|
|
|
+ assert.equal(
|
|
|
+ $select.find('option').length,
|
|
|
+ 2,
|
|
|
+ 'Only one more <option> element should be created'
|
|
|
+ );
|
|
|
+
|
|
|
+ data.select({
|
|
|
+ id: 'default'
|
|
|
+ });
|
|
|
+
|
|
|
+ assert.ok(
|
|
|
+ $select.find(':selected').data('data').extra,
|
|
|
+ '<option> default should have new data'
|
|
|
+ );
|
|
|
+
|
|
|
+ data.select({
|
|
|
+ id: 'One'
|
|
|
+ });
|
|
|
+
|
|
|
+ assert.ok(
|
|
|
+ $select.find(':selected').data('data').extra,
|
|
|
+ '<option> One should have new data'
|
|
|
+ );
|
|
|
+});
|
|
|
+
|
|
|
test('optgroup tags can also be generated', function (assert) {
|
|
|
var $select = $('#qunit-fixture .single-empty');
|
|
|
|