-
Notifications
You must be signed in to change notification settings - Fork 529
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
feat: remove is-promise
library
#2080
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2080 +/- ##
==========================================
- Coverage 96.57% 96.56% -0.02%
==========================================
Files 254 254
Lines 7626 7620 -6
Branches 1986 1986
==========================================
- Hits 7365 7358 -7
- Misses 261 262 +1 ☔ View full report in Codecov by Sentry. |
it('@JAEGER_API/FETCH_TRACE should return the promise', () => { | ||
const { payload } = jaegerApiActions.fetchTrace(id); | ||
expect(isPromise(payload)).toBeTruthy(); | ||
}); |
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.
Why are these tests removed? What is replacing them?
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.
These are unnecessary tests. Each of these fetchXYZ
functions is essentially createAction
wrapper for different JSON files accessed via the get JSON
function. Since the getJSON
function returns a promise, the results of these calls are guaranteed to be PromiseLike. I removed these tests as they are essentially type-checking, which should be TypeScript
's job.
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.
they are essentially type-checking, which should be TypeScript's job.
how is that type-checking achieved given that the source file in question is not in TS, but JS?
Also
Each of these fetchXYZ functions is essentially createAction wrapper
That's an implementation detail of those functions, but the tests were enforcing the public API. Implementations may change.
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.
Ahh, my bad. I completely missed the .js
extension. If we have to enforce the public API of these functions, then it would best to keep checking if we have a promise returned. I will revert the tests.
describe('allSettled', () => { | ||
it('validate responses', async () => { | ||
const res = await jaegerApiActions.allSettled([ | ||
Promise.resolve(1), | ||
// eslint-disable-next-line prefer-promise-reject-errors | ||
Promise.reject(2), | ||
Promise.resolve(3), | ||
]); | ||
|
||
expect(res).toEqual([ | ||
{ status: 'fulfilled', value: 1 }, | ||
{ status: 'rejected', reason: 2 }, | ||
{ status: 'fulfilled', value: 3 }, | ||
]); | ||
}); |
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.
I removed this test as we have now deprecated the custom implementation of allSettled
for the builtin Promise.allSettled
.
Signed-off-by: Eshaan Aggarwal <[email protected]>
Signed-off-by: Eshaan Aggarwal <[email protected]>
Signed-off-by: Eshaan Aggarwal <[email protected]>
I have reverted the tests testing the public API and removed the |
Have you considered converting packages/jaeger-ui/src/actions/jaeger-api.js to Typescript? |
I tried to do so but later decided to avoid doing it for two reasons:
I don't think these types enforce the |
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.
Thanks!
Which problem is this PR solving?
Fixes #2074
Description of the changes
is-promise
libraryPromise.allSettled
function (as described in a comment)There seems to be an unrelated test in
date.test.js
that fails after these changes. I have fixed the test with what I think the intended testing was supposed to do. Would appreciate a review on the same!How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test