-
-
Notifications
You must be signed in to change notification settings - Fork 213
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: [1502] Reduce duplication in tests #1681
base: master
Are you sure you want to change the base?
feat: [1502] Reduce duplication in tests #1681
Conversation
@@ -3,22 +3,18 @@ import Response from '../../src/fetch/Response.js'; | |||
import Headers from '../../src/fetch/Headers.js'; | |||
import DOMException from '../../src/exception/DOMException.js'; | |||
import DOMExceptionNameEnum from '../../src/exception/DOMExceptionNameEnum.js'; | |||
import AbortController from '../../src/fetch/AbortController.js'; |
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 were unused.
8a36bac
to
73fbdc1
Compare
73fbdc1
to
4c77812
Compare
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.
Sorry for taking some time to review. I think it looks good! 🙂 It definitely reduces duplicated code.
I had one comment, but it doesn't have to be done in this PR. Let me know what you think.
@@ -30,6 +26,42 @@ const PLATFORM = | |||
process.arch; | |||
|
|||
describe('Fetch', () => { | |||
async function mockNetwork( |
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 think we could move this to test/setup.ts
(like mockModule()
), but it doesn't have to be done in this PR
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.
Hmm - In that case mockAsyncNetwork for now? It's actually something to understand as to if it would be possible to make SyncFetch consistent with Fetch so mockNetwork would apply to both of 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.
Yes, mockAsyncNetwork would work 🙂
I'll start off with some examples before fully committing as there a lot of tests. If you're happy with these changes feel free to merge this and I'll continue with the refactor. By the way, perhaps you should allow for refactor type in commit message.