-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update promise.wait to throw an error when timeout reached or interru…
…pted (#723) * Update promise.wait to throw an error when timeout reached or interrupted * Revert some formatting changes * Fix lint error * Add test to demonstrate functionality * Update lua/orgmode/utils/promise.lua Co-authored-by: Kristijan Husak <husakkristijan@gmail.com> --------- Co-authored-by: Kristijan Husak <husakkristijan@gmail.com>
- Loading branch information
1 parent
d4cc321
commit 03a2078
Showing
2 changed files
with
27 additions
and
2 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,14 @@ | ||
local Promise = require('orgmode.utils.promise') | ||
|
||
describe('Promise', function() | ||
it('should throw an error when wait exceeds its timeout', function() | ||
-- Create a promise that will never resolve or reject | ||
local promise = Promise.new(function() end) | ||
|
||
-- We expect an error to occur here when the timeout is exceeded | ||
assert.is.error(function() | ||
-- Provide a smaller timeout so our test doesn't wait 5 seconds | ||
promise:wait(50) | ||
end) | ||
end) | ||
end) |