-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix crashes where workspaceFolders was undefined * Fix fallback to built-in lsp when bsdk cannot be resolved * Better error message wording
- Loading branch information
1 parent
79c8964
commit e89413f
Showing
3 changed files
with
62 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
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,32 @@ | ||
import { expect } from 'chai'; | ||
|
||
export function expectThrows(callback: () => any, expectedMessage: string | undefined = undefined, failedTestMessage = 'Expected to throw but did not') { | ||
let wasExceptionThrown = false; | ||
try { | ||
callback(); | ||
} catch (e) { | ||
wasExceptionThrown = true; | ||
if (expectedMessage) { | ||
expect(e.message).to.eql(expectedMessage); | ||
} | ||
} | ||
if (wasExceptionThrown === false) { | ||
throw new Error(failedTestMessage); | ||
} | ||
} | ||
|
||
|
||
export async function expectThrowsAsync(callback: () => any, expectedMessage: string | undefined = undefined, failedTestMessage = 'Expected to throw but did not') { | ||
let wasExceptionThrown = false; | ||
try { | ||
await Promise.resolve(callback()); | ||
} catch (e) { | ||
wasExceptionThrown = true; | ||
if (expectedMessage) { | ||
expect(e.message).to.eql(expectedMessage); | ||
} | ||
} | ||
if (wasExceptionThrown === false) { | ||
throw new Error(failedTestMessage); | ||
} | ||
} |