web/test/jstests/test_htmlhelpers.js
author Julien Cristau <julien.cristau@logilab.fr>
Mon, 18 May 2015 20:00:06 +0200
changeset 10436 6493c8bf521d
parent 10429 98ea2b865210
permissions -rw-r--r--
[test] don't leave NULL columns around when making an attribute required It doesn't matter on sqlite (it doesn't do ALTER COLUMN), but when running this test on postgresql it fails to add the 'NOT NULL' constraint otherwise.

$(document).ready(function() {

    QUnit.module("module2", {
      setup: function() {
        $('#qunit-fixture').append('<select id="theselect" multiple="multiple" size="2">' +
    			'</select>');
      }
    });

    QUnit.test("test first selected", function (assert) {
        $('#theselect').append('<option value="foo">foo</option>' +
    			     '<option selected="selected" value="bar">bar</option>' +
    			     '<option value="baz">baz</option>' +
    			     '<option selected="selecetd"value="spam">spam</option>');
        var selected = firstSelected(document.getElementById("theselect"));
        assert.equal(selected.value, 'bar');
    });

    QUnit.test("test first selected 2", function (assert) {
        $('#theselect').append('<option value="foo">foo</option>' +
    			     '<option value="bar">bar</option>' +
    			     '<option value="baz">baz</option>' +
    			     '<option value="spam">spam</option>');
        var selected = firstSelected(document.getElementById("theselect"));
        assert.equal(selected, null);
    });

    QUnit.module("visibilty");
    QUnit.test('toggleVisibility', function (assert) {
        $('#qunit-fixture').append('<div id="foo"></div>');
        toggleVisibility('foo');
        assert.ok($('#foo').hasClass('hidden'), 'check hidden class is set');
    });

});