Esempio n. 1
0
test('current gets options with implicit value', function (assert) {
    var $select = $('#qunit-fixture .single');

    var data = new SelectData($select, selectOptions);

    $select.val('One');

    data.current(function (val) {
        assert.equal(
            val.length,
            1,
            'There should only be one selected value'
        );

        var option = val[0];

        assert.equal(
            option.id,
            'One',
            'The id should be the same as the option text'
        );

        assert.equal(
            option.text,
            'One',
            'The text should be the same as the option text'
        );
    });
});
Esempio n. 2
0
test('current gets options with explicit value', function (assert) {
    var $select = $('#qunit-fixture .single');

    var $option = $('<option value="1">One</option>');
    $select.append($option);

    var data = new SelectData($select, selectOptions);

    $select.val('1');

    data.current(function (data) {
        assert.equal(
            data.length,
            1,
            'There should be one selected option'
        );

        var option = data[0];

        assert.equal(
            option.id,
            '1',
            'The option value should be the selected id'
        );

        assert.equal(
            option.text,
            'One',
            'The text should match the text for the option tag'
        );
    });
});
Esempio n. 3
0
test('current gets default for single', function (assert) {
    var $select = $('#qunit-fixture .single');

    var data = new SelectData($select, selectOptions);

    data.current(function (data) {
        assert.equal(
            data.length,
            1,
            'There should only be one selected option'
        );

        var option = data[0];

        assert.equal(
            option.id,
            'One',
            'The value of the option tag should be the id'
        );

        assert.equal(
            option.text,
            'One',
            'The text within the option tag should be the text'
        );
    });
});
Esempio n. 4
0
test('current gets default for multiple', function (assert) {
    var $select = $('#qunit-fixture .multiple');

    var data = new SelectData($select, selectOptions);

    data.current(function (data) {
        assert.equal(
            data.length,
            0,
            'Multiple selects have no default selection.'
        );
    });
});