diff options
author | Peter Wagenet <peter.wagenet@gmail.com> | 2012-11-02 10:39:49 -0700 |
---|---|---|
committer | Peter Wagenet <peter.wagenet@gmail.com> | 2012-11-02 10:39:49 -0700 |
commit | 39832c06338c3412bae22597acfc98002d4519bf (patch) | |
tree | 8ba2c035c26a78833dea3e2a0cb3c2eeae2f7afd /spec/qunit_spec.js | |
parent | a927a9b0adc39660f0794b9b210c9db2f7ddecd9 (diff) | |
download | handlebars.js-39832c06338c3412bae22597acfc98002d4519bf.zip handlebars.js-39832c06338c3412bae22597acfc98002d4519bf.tar.gz handlebars.js-39832c06338c3412bae22597acfc98002d4519bf.tar.bz2 |
Fix handling of Errors in Chrome
Diffstat (limited to 'spec/qunit_spec.js')
-rw-r--r-- | spec/qunit_spec.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/spec/qunit_spec.js b/spec/qunit_spec.js index 293c413..5c94253 100644 --- a/spec/qunit_spec.js +++ b/spec/qunit_spec.js @@ -61,13 +61,27 @@ function compileWithPartials(string, hashOrArray, partials) { } function shouldThrow(fn, exception, message) { - var caught = false; + var caught = false, + exType, exMessage; + + if (exception instanceof Array) { + exType = exception[0]; + exMessage = exception[1]; + } else if (typeof exception === 'string') { + exType = Error; + exMessage = exception; + } else { + exType = exception; + } + try { fn(); } catch (e) { - if (e instanceof exception) { - caught = true; + if (e instanceof exType) { + if (!exMessage || e.message === exMessage) { + caught = true; + } } } @@ -480,14 +494,14 @@ test("rendering undefined partial throws an exception", function() { shouldThrow(function() { var template = CompilerContext.compile("{{> whatever}}"); template(); - }, Handlebars.Exception, "Should throw exception"); + }, [Handlebars.Exception, 'The partial whatever could not be found'], "Should throw exception"); }); test("rendering template partial in vm mode throws an exception", function() { shouldThrow(function() { var template = CompilerContext.compile("{{> whatever}}"); template(); - }, Handlebars.Exception, "Should throw exception"); + }, [Handlebars.Exception, 'The partial whatever could not be found'], "Should throw exception"); }); test("rendering function partial in vm mode", function() { |