From 98cde7ca7b570b52c2b47af7547e6ec1da3a2071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Ku=CC=88hn?= Date: Thu, 2 Nov 2017 13:03:44 +0100 Subject: [PATCH] [IMP] web: createParent in test_utils.js New utility function to create a parent widget from given params that will be given to addMockEnvironment. --- addons/web/static/tests/helpers/test_utils.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js index a8a4612b38f..9ab53186c1e 100644 --- a/addons/web/static/tests/helpers/test_utils.js +++ b/addons/web/static/tests/helpers/test_utils.js @@ -398,6 +398,19 @@ function createModel(params) { return model; } +/** + * create a widget parent from given parameters. + * + * @param {Object} params This object will be given to addMockEnvironment, so + * any parameters from that method applies + * @returns {Widget} + */ +function createParent(params) { + var widget = new Widget(); + addMockEnvironment(widget, params); + return widget; +} + /** * simulate a drag and drop operation between 2 jquery nodes: $el and $to. * This is a crude simulation, with only the mousedown, mousemove and mouseup @@ -554,6 +567,7 @@ return $.when( createView: createView, createAsyncView: createAsyncView, createModel: createModel, + createParent: createParent, addMockEnvironment: addMockEnvironment, dragAndDrop: dragAndDrop, triggerMouseEvent: triggerMouseEvent,