Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

OlaviSau
Copy link
Contributor

@OlaviSau OlaviSau commented Jan 9, 2025

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.

@OlaviSau OlaviSau requested a review from capricorn86 as a code owner January 9, 2025 06:38
@@ -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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were unused.

@OlaviSau OlaviSau force-pushed the feature-1502-fetch-test-improvements branch from 8a36bac to 73fbdc1 Compare January 9, 2025 06:43
@OlaviSau OlaviSau force-pushed the feature-1502-fetch-test-improvements branch from 73fbdc1 to 4c77812 Compare January 9, 2025 06:46
Copy link
Owner

@capricorn86 capricorn86 left a 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(
Copy link
Owner

@capricorn86 capricorn86 Jan 14, 2025

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

Copy link
Contributor Author

@OlaviSau OlaviSau Jan 15, 2025

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 😁

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, mockAsyncNetwork would work 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants