diff options
| author | Vincent Schippefilt <vsc@odoo.com> | 2019-03-06 14:02:32 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-03-06 20:07:17 +0100 |
| commit | ab56e637b7f97ddcdbcc9baea99ae097e342409c (patch) | |
| tree | 4cb47da9f7ef89b19d18429220a7507470ec12a9 /addons/web/static/tests/helpers/qunit_asserts.js | |
| parent | eeed894fd50e477135e1ac9a82f6e98ce063ab90 (diff) | |
[REF] web: adapt code after jQuery update
Part of task 1896658
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Christophe Matthieu <chm@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
Co-authored-by: svs-odoo <svs@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Diffstat (limited to 'addons/web/static/tests/helpers/qunit_asserts.js')
| -rw-r--r-- | addons/web/static/tests/helpers/qunit_asserts.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/addons/web/static/tests/helpers/qunit_asserts.js b/addons/web/static/tests/helpers/qunit_asserts.js index bce6ef2a777..e8f9948d347 100644 --- a/addons/web/static/tests/helpers/qunit_asserts.js +++ b/addons/web/static/tests/helpers/qunit_asserts.js @@ -37,7 +37,7 @@ function _checkClass(w, className, shouldHaveClass, msg) { var descr = `${shouldHaveClass ? 'hasClass' : 'doesNotHaveClass'} ${className}`; QUnit.assert.ok(false, `Assertion '${descr}' targets ${$el.length} elements instead of 1`); } else { - msg = msg || `target ${$el.selector || ''} should ${shouldHaveClass ? '' : 'not'} have class ${className}`; + msg = msg || `target should ${shouldHaveClass ? '' : 'not'} have class ${className}`; var hasClass = $el.hasClass(className); var condition = shouldHaveClass ? hasClass : !hasClass; QUnit.assert.ok(condition, msg); @@ -63,8 +63,15 @@ function _checkVisible(w, shouldBeVisible, msg) { var descr = `${shouldBeVisible ? 'isVisible' : 'isNotVisible'}`; QUnit.assert.ok(false, `Assertion '${descr}' targets ${$el.length} elements instead of 1`); } else { - msg = msg || `target ${$el.selector} should ${shouldBeVisible ? '' : 'not'} be visible`; + msg = msg || `target should ${shouldBeVisible ? '' : 'not'} be visible`; var isVisible = $el.is(':visible'); + if (isVisible) { + // Additional test to see if $el is really visible, since jQuery + // considers an element visible if it has a DOWRect, even if its + // width and height are equal to zero. + var boundingClientRect = $el[0].getBoundingClientRect(); + isVisible = boundingClientRect.width + boundingClientRect.height; + } var condition = shouldBeVisible ? isVisible : !isVisible; QUnit.assert.ok(condition, msg); } @@ -96,9 +103,7 @@ function containsN(w, selector, n, msg) { var $matches = $el.find(selector); if (!msg) { msg = `Selector '${selector}' should have exactly ${n} matches`; - if ($el.selector) { - msg += ` (inside '${$el.selector}')`; - } + msg += ` (inside the target)`; } QUnit.assert.strictEqual($matches.length, n, msg); } @@ -181,7 +186,7 @@ function hasAttrValue(w, attr, value, msg) { var descr = `hasAttrValue (${attr}: ${value})`; QUnit.assert.ok(false, `Assertion '${descr}' targets ${$el.length} elements instead of 1`); } else { - msg = msg || `attribute '${attr}' of target ${$el.selector || ''} should be '${value}'`; + msg = msg || `attribute '${attr}' of target should be '${value}'`; QUnit.assert.strictEqual($el.attr(attr), value, msg); } } |
