Added test cases for async errors and timeouts

This commit is contained in:
Patrick Steele-Idem 2014-12-15 10:24:15 -07:00
parent 2e7b59e10b
commit fe3753d644
5 changed files with 48 additions and 0 deletions

View File

@ -281,4 +281,32 @@ describe('marko/marko-async' , function() {
}, done);
});
it("should allow for alternative error message (sync)", function(done) {
testRender('test-project/html-templates/async-fragment-error.marko', {
userInfo: function(done) {
done(new Error('Invalid user'));
}
}, done);
});
it("should allow for alternative error message (async)", function(done) {
testRender('test-project/html-templates/async-fragment-error.marko', {
userInfo: function(done) {
setTimeout(function() {
done(new Error('Invalid user'));
}, 200);
}
}, done);
});
it("should allow for alternative timeout message", function(done) {
testRender('test-project/html-templates/async-fragment-timeout.marko', {
userInfo: function(done) {
setTimeout(function() {
done(null, {});
}, 600);
}
}, done);
});
});

View File

@ -0,0 +1,9 @@
<async-fragment data-provider="data.userInfo" var="user">
<async-fragment-error>
1-An error has occurred!
</async-fragment-error>
1
</async-fragment>
<async-fragment data-provider="data.userInfo" var="user" error-message="2-An error has occurred!">
2
</async-fragment>

View File

@ -0,0 +1 @@
1-An error has occurred!2-An error has occurred!

View File

@ -0,0 +1,9 @@
<async-fragment data-provider="data.userInfo" var="user" timeout="300">
<async-fragment-timeout>
1-A timeout has occurred!
</async-fragment-timeout>
1
</async-fragment>
<async-fragment data-provider="data.userInfo" var="user" timeout-message="2-A timeout has occurred!" timeout="300">
2
</async-fragment>

View File

@ -0,0 +1 @@
1-A timeout has occurred!2-A timeout has occurred!