streams/vendor/svg-edit/svgedit/test/qunit/qunit-assert-expectOutOfBoundsException.js

33 lines
745 B
JavaScript
Raw Normal View History

2019-11-11 01:11:51 +00:00
/**
* Expects an out of bounds `INDEX_SIZE_ERR` exception.
* @param {GenericObject} obj
* @param {GenericCallback} fn
2019-12-04 05:46:07 +00:00
* @param {any} arg1
2019-11-11 01:11:51 +00:00
* @returns {void}
*/
function expectOutOfBoundsException (obj, fn, arg1) {
const expected = true;
const message = 'Caught an INDEX_SIZE_ERR exception';
let result = false;
try {
obj[fn](arg1);
} catch (e) {
if (e.code === 1) {
result = true;
}
}
const actual = result;
this.pushResult({result, actual, expected, message});
}
/**
* @param {external:qunit} QUnit
* @returns {external:qunit} The same instance passed in after extending
*/
export default function extend (QUnit) {
QUnit.extend(QUnit.assert, {
expectOutOfBoundsException
});
return QUnit;
}