cubicweb/web/test/data/static/jstests/test_htmlhelpers.js
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 18 Nov 2016 17:50:56 +0100
changeset 11891 67185e65f020
parent 11057 0b59724cb3f2
permissions -rw-r--r--
[entity/optimization] Cache rset when entity.related is called with entities=False If fail to see why we couldn't cache in this case, while this is important for optimization reason: when doing a single HTTP request, some queries are done two or three times because of predicates / uicfg or alike. Also always store tuple and not list in the cache, because: * else we get some regression * and inconsistent result type (tuple or list) * and it simply feels better to cache an unmutable object.

$(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');
    });

});