Skip to content

Commit

Permalink
✅ Update test for Future
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEEs committed Apr 30, 2021
1 parent 01db015 commit 5c725bd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/alizarin_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,29 @@ describe Future do
ret = String.new JSC.to_string script_result
ret.should eq "undefined"
end

it "A future can not resolve after it was rejected" do
eval_js <<-JS
window.returned_value = undefined;
var future = new Future(function(resolve,reject){
reject("Oops!");
}).then(function(file_content, resolve, reject){
//resolve(file_content);
}).catch(function(file_content){
try{
future.resolve(1);
}catch{
window.returned_value = "Cannot resolve this Future";
}
});
true;
JS
script_result
sleep 0.5
eval_js <<-JS
window.returned_value;
JS
ret = String.new JSC.to_string script_result
ret.should eq "Cannot resolve this Future"
end
end

0 comments on commit 5c725bd

Please sign in to comment.