~tempo-openerp/+junk/loewert-prod

« back to all changes in this revision

Viewing changes to addons/web/static/test/registry.js

  • Committer: jbe at tempo-consulting
  • Date: 2013-08-21 08:48:11 UTC
  • Revision ID: jbe@tempo-consulting.fr-20130821084811-913uo4l7b5ayxq8m
[NEW] Création de la branche trunk Loewert

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
openerp.testing.section('registry', {
 
2
    dependencies: ['web.corelib'],
 
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
});