diff options
| author | Julien Mougenot <jum@odoo.com> | 2020-02-25 12:52:41 +0000 |
|---|---|---|
| committer | Julien Mougenot <jum@odoo.com> | 2020-03-13 09:37:29 +0000 |
| commit | 384e516218375000461aa3fcb0ac1b9eaa960fb3 (patch) | |
| tree | 89d6faece5edea9a4f182b7a6d2e83cbb6f540ce /addons/web/static/tests/helpers/test_utils_modal.js | |
| parent | 11ba58a311311b798a68183df18673e562bb97d3 (diff) | |
[REF] web: Update generic files
General cleaning of some helpers and generic files. The idea is that they are
less likely to be entirely re-written in the near future so this is a way to
keep the code clean, readable and compliant to the current standards. Changes include:
- Use of async/await when possible
- Use of const/let instead of var
- Removal of underscore.js
- Use of native JS instead of jQuery when possible
The logic of the affected code remains the same.
Diffstat (limited to 'addons/web/static/tests/helpers/test_utils_modal.js')
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils_modal.js | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/addons/web/static/tests/helpers/test_utils_modal.js b/addons/web/static/tests/helpers/test_utils_modal.js index 5587eecfc01..ca3eeef11a7 100644 --- a/addons/web/static/tests/helpers/test_utils_modal.js +++ b/addons/web/static/tests/helpers/test_utils_modal.js @@ -1,36 +1,26 @@ odoo.define('web.test_utils_modal', function (require) { -"use strict"; + "use strict"; -/** - * Modal Test Utils - * - * This module defines various utility functions to help test pivot views. - * - * Note that all methods defined in this module are exported in the main - * testUtils file. - */ + /** + * Modal Test Utils + * + * This module defines various utility functions to help test pivot views. + * + * Note that all methods defined in this module are exported in the main + * testUtils file. + */ -var core = require('web.core'); -var concurrency = require('web.concurrency'); + const { _t } = require('web.core'); + const testUtilsDom = require('web.test_utils_dom'); -/** - * Click on a button in the footer of a modal (which contains a given string). - * Note that this method checks the unicity of the button. - * - * @param {string} text (in english: this method will perform the translation) - */ -function clickButton(text) { - var selector = `.modal-footer button:contains(${core._t(text)})`; - var $button = $(selector); - if ($button.length !== 1) { - throw new Error(`Found ${$button.length} button(s) containing '${text}'`); + /** + * Click on a button in the footer of a modal (which contains a given string). + * + * @param {string} text (in english: this method will perform the translation) + */ + function clickButton(text) { + return testUtilsDom.click($(`.modal-footer button:contains(${_t(text)})`)); } - $button.click(); - return concurrency.delay(0); -} - -return { - clickButton: clickButton, -}; + return { clickButton }; }); |
