[FIX] web: manual update of select2 lib to 3.5.1 version
[odoo/odoo.git] / addons / web / static / test / registry.js
1 openerp.testing.section('registry', {
2     dependencies: ['web.core'],
3     setup: function (instance) {
4         instance.web.Foo = {};
5         instance.web.Bar = {};
6         instance.web.Foo2 = {};
7     }
8 }, function (test) {
9     test('key set', function (instance) {
10         var reg = new instance.web.Registry();
11
12         reg.add('foo', 'instance.web.Foo')
13            .add('bar', 'instance.web.Bar');
14         strictEqual(reg.get_object('bar'), instance.web.Bar);
15     });
16     test('extension', function (instance) {
17         var reg = new instance.web.Registry({
18             foo: 'instance.web.Foo',
19             bar: 'instance.web.Bar'
20         });
21
22         var reg2 = reg.extend({ 'foo': 'instance.web.Foo2' });
23         strictEqual(reg.get_object('foo'), instance.web.Foo);
24         strictEqual(reg2.get_object('foo'), instance.web.Foo2);
25     });
26     test('remain-linked', function (instance) {
27         var reg = new instance.web.Registry({
28             foo: 'instance.web.Foo',
29             bar: 'instance.web.Bar'
30         });
31
32         var reg2 = reg.extend();
33         reg.add('foo2', 'instance.web.Foo2');
34         strictEqual(reg.get_object('foo2'), instance.web.Foo2);
35         strictEqual(reg2.get_object('foo2'), instance.web.Foo2);
36     });
37     test('multiget', function (instance) {
38         var reg = new instance.web.Registry({
39             foo: 'instance.web.Foo',
40             bar: 'instance.web.Bar'
41         });
42
43         strictEqual(reg.get_any(['qux', 'grault', 'bar', 'foo']),
44                     instance.web.Bar);
45     });
46     test('extended-multiget', function (instance) {
47         var reg = new instance.web.Registry({
48             foo: 'instance.web.Foo',
49             bar: 'instance.web.Bar'
50         });
51         var reg2 = reg.extend();
52         strictEqual(reg2.get_any(['qux', 'grault', 'bar', 'foo']),
53                     instance.web.Bar);
54     });
55 });