diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/web/static/tests/chrome/menu_tests.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/web/static/tests/chrome/menu_tests.js')
| -rw-r--r-- | addons/web/static/tests/chrome/menu_tests.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/addons/web/static/tests/chrome/menu_tests.js b/addons/web/static/tests/chrome/menu_tests.js new file mode 100644 index 00000000..a50e2189 --- /dev/null +++ b/addons/web/static/tests/chrome/menu_tests.js @@ -0,0 +1,47 @@ +odoo.define('web.menu_tests', function (require) { + "use strict"; + + const testUtils = require('web.test_utils'); + const Menu = require('web.Menu'); + const SystrayMenu = require('web.SystrayMenu'); + const Widget = require('web.Widget'); + + + QUnit.module('chrome', {}, function () { + QUnit.module('Menu'); + + QUnit.test('Systray on_attach_callback is called', async function (assert) { + assert.expect(4); + + const parent = await testUtils.createParent({}); + + // Add some widgets to the systray + const Widget1 = Widget.extend({ + on_attach_callback: () => assert.step('on_attach_callback widget1') + }); + const Widget2 = Widget.extend({ + on_attach_callback: () => assert.step('on_attach_callback widget2') + }); + SystrayMenu.Items = [Widget1, Widget2]; + + testUtils.mock.patch(SystrayMenu, { + on_attach_callback: function () { + assert.step('on_attach_callback systray'); + this._super(...arguments); + } + }); + + const menu = new Menu(parent, {children: []}); + await menu.appendTo($('#qunit-fixture')); + + assert.verifySteps([ + 'on_attach_callback systray', + 'on_attach_callback widget1', + 'on_attach_callback widget2', + ]); + testUtils.mock.unpatch(SystrayMenu); + parent.destroy(); + }); + }); + +}); |
