-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #46 - Should handle exceptions in with/withOnShow
- Loading branch information
Showing
3 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
</head> | ||
<body> | ||
<div data-bind="text: thisPropertyShouldNotExist"> | ||
</div> | ||
<div id="errorDiv">Test</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Should trigger onBindingError</title> | ||
<script type="text/javascript" src="../lib/jquery-1.7.2.min.js"></script> | ||
<script type="text/javascript" src="../lib/underscore-min.js"></script> | ||
<script type="text/javascript" src="../lib/knockout-2.1.0.js"></script> | ||
<script type="text/javascript" src="../lib/jquery.ba-hashchange.min.js"></script> | ||
<script type="text/javascript" src="../pager.js"></script> | ||
|
||
<link rel="stylesheet" href="../lib/qunit.css"/> | ||
</head> | ||
<body> | ||
|
||
<div id="qunit"></div> | ||
|
||
<div data-bind="page: {id: 'start', source: '../test-data/error.html', onBindingError: bindingError}"> | ||
|
||
</div> | ||
|
||
<script type="text/javascript"> | ||
|
||
var globalIsTriggered = false; | ||
|
||
var localIsTriggered = false; | ||
|
||
|
||
var viewModel = { | ||
bindingError:function () { | ||
localIsTriggered = true; | ||
} | ||
}; | ||
|
||
pager.extendWithPage(viewModel); | ||
pager.onBindingError.add(function () { | ||
globalIsTriggered = true; | ||
}); | ||
ko.applyBindings(viewModel); | ||
|
||
pager.startHashChange(); | ||
|
||
</script> | ||
|
||
<script type="text/javascript" src="../lib/qunit-until.js"></script> | ||
<script type="text/javascript" src="../lib/qunit.js"></script> | ||
|
||
<script type="text/javascript"> | ||
|
||
asyncTest("Should trigger onBindingError", function () { | ||
|
||
until(function () { | ||
return $('#errorDiv').is(':visible'); | ||
}, function () { | ||
assert.equal(globalIsTriggered, true, "global error should be triggered"); | ||
assert.equal(localIsTriggered, true, "local error should be triggered"); | ||
start(); | ||
}); | ||
|
||
|
||
}); | ||
</script> | ||
|
||
|
||
</body> | ||
</html> |