blob: 941e275f19b395029bbf9a15db4a5a91a6c178f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
odoo.define('web.systray_tests', function (require) {
"use strict";
var testUtils = require('web.test_utils');
var SystrayMenu = require('web.SystrayMenu');
var Widget = require('web.Widget');
QUnit.test('Adding async components to the registry respects the sequence', async function (assert) {
assert.expect(2);
var parent = await testUtils.createParent({});
var prom = testUtils.makeTestPromise();
var synchronousFirstWidget = Widget.extend({
sequence: 3, // bigger sequence means more to the left
start: function () {
this.$el.addClass('first');
}
});
var asynchronousSecondWidget = Widget.extend({
sequence: 1, // smaller sequence means more to the right
willStart: function () {
return prom;
},
start: function () {
this.$el.addClass('second');
}
});
SystrayMenu.Items = [synchronousFirstWidget, asynchronousSecondWidget];
var menu = new SystrayMenu(parent);
menu.appendTo($('#qunit-fixture'));
await testUtils.nextTick();
prom.resolve();
await testUtils.nextTick();
assert.hasClass(menu.$('div:eq(0)'), 'first');
assert.hasClass(menu.$('div:eq(1)'), 'second');
parent.destroy();
})
});
|