javascript - Testing if JS method throws RangeError with QUnit -



javascript - Testing if JS method throws RangeError with QUnit -

i made javascript unit tests qunit library, want test if method throws rangeerror. has done in way:

qunit.test("resolve slide animation left", function( assert ) { var myowncreator = new myowncreator(); assert.equal(myowncreator.resolveanimationtype("slideside", "show", "left"), "slide-left-in"); assert.equal(myowncreator.resolveanimationtype("slideside", "hide", "left"), "slide-left-out"); assert.throws(myowncreator.resolveanimationtype("slideside", "hide"), new rangeerror(), " if animation type 'slideside', have provide right direction" + "to identify animation properly, direction cannot 'undefined'"); });

first , sec test passed, because animation classes resolved function (,,slide-...") ok. 3rd test died:

died on test #3 @ file...

because throws rangeerror. it's ok throws rangeerror, don't understand how can grab in unit test, ,,ok" information. if understand qunit documentation: qunit throws documentation

i ok: pass function throws error, instance of expected error , expected message. decide help me, happy - give thanks in advance.

i found reply on own. instead calling function:

assert.throws(myowncreator.resolveanimationtype("slideside", "hide"), new rangeerror()....

i should pass assert.throws() function phone call function, this:

assert.throws(function(){ myowncreator.resolveanimationtype("slideside", "hide"); }, new rangeerror(--message function should throw in error--)...

javascript unit-testing assert qunit throws

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -