-
Notifications
You must be signed in to change notification settings - Fork 6.4k
feat(testing): add tests for src/browser/pages/vscode to hit 100% coverage #4055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4055 +/- ##
=======================================
Coverage 63.51% 63.51%
=======================================
Files 36 36
Lines 1872 1872
Branches 379 379
=======================================
Hits 1189 1189
Misses 580 580
Partials 103 103
Continue to review full report at Codecov.
|
|
✨ Coder.com for PR #4055 deployed! It will be updated on every commit.
|
889d476 to
011e8bf
Compare
| * for getNlsConfiguration. | ||
| */ | ||
| export function createBundlePath(_resolvedLanguagePackCoreLocation: string, bundle: string) { | ||
| export function createBundlePath(_resolvedLanguagePackCoreLocation: string | undefined, bundle: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 updated the signature to match the actual value passed in _resolvedLanguagePackCoreLocation's type is string | undefined
| // so we'll leave it alone for now. | ||
| // FIXME: Only works if path separators are /. | ||
| return _resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json" | ||
| return (_resolvedLanguagePackCoreLocation || "") + "/" + bundle.replace(/\//g, "!") + ".nls.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Originally, we were using _resolvedLanguagePackCoreLocation or passing in an empty string. We moved the logic from outside the function into the function since the caller shouldn't have to change the argument functions if the value is undefined. Instead, the function should handle this.
| type LoadBundleCallback = (_: undefined, result?: string) => void | ||
|
|
||
| nlsConfig.loadBundle = (bundle: string, _language: string, cb: LoadBundleCallback): void => { | ||
| nlsConfig.loadBundle = async (bundle: string, _language: string, cb: LoadBundleCallback): Promise<void> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Originally, this function was not using async/await. I then realized we had the fetch call and the .then chain. I refactored this so it was easy to test. Now it's clear to the caller this function has asynchronous logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 👍
| if (result) { | ||
| return cb(undefined, result) | ||
| } | ||
| // FIXME: Only works if path separators are /. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Removed this comment because it's related to createBundlePath and explained in a comment near that function with more details.
| const actual = createBundlePath(_resolvedLangaugePackCoreLocation, bundle) | ||
| expect(actual).toBe(expected) | ||
| }) | ||
| it("should return the correct path (even if _resolvedLangaugePackCoreLocation is undefined)", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ This check was added after modifying the createBundlePath function signature.
011e8bf to
f4b0ab3
Compare
f4b0ab3 to
79b4e47
Compare
This PR adds full test coverage for
src/browser/pages/vscode.tsFixes #4052