mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-22 17:15:28 +00:00
33 lines
745 B
JavaScript
33 lines
745 B
JavaScript
|
/**
|
||
|
* Expects an out of bounds `INDEX_SIZE_ERR` exception.
|
||
|
* @param {GenericObject} obj
|
||
|
* @param {GenericCallback} fn
|
||
|
* @param {Any} arg1
|
||
|
* @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;
|
||
|
}
|