odoo-13.0/addons/web/static/tests/helpers/qunit_asserts.js
/**
 * Helper function, to check if a given element
 * - is unique (if it is a jquery node set)
 * - has (or has not) a css class
 *
 * @private
 * @param {Widget|jQuery|HTMLElement} w
 * @param {string} className
 * @param {boolean} shouldHaveClass
 * @param {string} [msg]
 */
Helper function, to check if a given element
- is unique (if it is a jquery node set)
- has (or has not) a css class


Helper function to check if a given element - is unique ( if it is a jquery node set ) - has ( or has not ) a css class
function _checkClass(w, className, shouldHaveClass, msg) {
    var $el = w instanceof Widget ? w.$el :
              w instanceof HTMLElement ? $(w) :
              w;  
    if ($el.length !== 1) {
        var descr = `${shouldHaveClass ? 'hasClass' : 'doesNotHaveClass'} ${className}`;
        QUnit.assert.ok(false, `Assertion '${descr}' targets ${$el.length} elements instead of 1`);
    } else {
        msg = msg || `target should ${shouldHaveClass ? '' : 'not'} have class ${className}`;
        var hasClass = $el.hasClass(className);
        var condition = shouldHaveClass ? hasClass : !hasClass;
        QUnit.assert.ok(condition, msg);
    }
}
function _checkClass ( w , className , shouldHaveClass , msg ) { var $el = w instanceof Widget ? w . $el : w instanceof HTMLElement ? $ ( w ) : w ; if ( $el . length !== 1 ) { var descr = ` ${ shouldHaveClass ? 'hasClass' : 'doesNotHaveClass' } ${ className } ` ; QUnit . assert . ok ( false , ` ${ descr } ${ $el . length } ` ) ; } else { msg = msg || ` ${ shouldHaveClass ? '' : 'not' } ${ className } ` ; var hasClass = $el . hasClass ( className ) ; var condition = shouldHaveClass ? hasClass : ! hasClass ; QUnit . assert . ok ( condition , msg ) ; } }
Helper function, to check if a given element
 - is unique (if it is a jquery node set)
 - has (or has not) a css class
Helper function to check if a given element - is unique ( if it is a jquery node set ) - has ( or has not ) a css class
// jquery element