[TEST] that by default the list view renders each row with a selection checkbox
[odoo/odoo.git] / addons / base / static / test / list.js
1 $(document).ready(function () {
2     /**
3      * Tests a jQuery collection against a selector ("ands" the .is() of each
4      * member of the collection, instead of "or"-ing them)
5      *
6      * @param {jQuery} $c a jQuery collection object
7      * @param {String} selector the selector to test the collection against
8      */
9     var are = function ($c, selector) {
10         return ($c.filter(function () { return $(this).is(selector); }).length
11                 === $c.length);
12     };
13
14     var fvg = {fields_view: {
15         'fields': [],
16         'arch': {
17             'attrs': {string: ''}
18         }
19     }};
20
21     var openerp;
22     module("ListView", {
23         setup: function () {
24             openerp = window.openerp.init(true);
25             window.openerp.base.chrome(openerp);
26             // views loader stuff
27             window.openerp.base.views(openerp);
28             window.openerp.base.list(openerp);
29         }
30     });
31
32     asyncTest('render selection checkboxes', 2, function () {
33         var listview = new openerp.base.ListView(
34                 {}, null,
35                 'qunit-fixture', {model: null});
36
37         listview.on_loaded(fvg);
38
39         listview.do_fill_table([{}, {}, {}]).then(function () {
40             ok(are(listview.$element.find('tbody th'),
41                    '.oe-record-selector'));
42             ok(are(listview.$element.find('tbody th input'),
43                    ':checkbox:not([name])'));
44             start();
45         });
46     });
47     
48 });