From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/web/static/tests/chrome/menu_tests.js | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 addons/web/static/tests/chrome/menu_tests.js (limited to 'addons/web/static/tests/chrome/menu_tests.js') 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(); + }); + }); + +}); -- cgit v1.2.3