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

code review suggestions #45

Merged
merged 3 commits into from
Jan 7, 2024
Merged

Conversation

stackoverfloweth
Copy link
Contributor

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we're importing getInitialUrl and testing that specifically this is still testing createRouter. So I wouldn't rename these test files.

import { createRouter } from '@/utilities/createRouter'
import { component } from '@/utilities/testHelpers'

describe('getInitialRoute', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think every test should be wrapped in a describe? Vitest automatically groups tests by their file so IMO wrapping all the tests in a describe with the name of the utility being tested (which is the same as the name of the file) is not needed and we should reserve describe for organizing larger test files where we want to group tests of similar nature. If every test is in a single describe we don't need it IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Abstracting this means less code in createRouter so I'm fine with this. But I don't think an isBrowser existing in a function means it much be abstracted.


test('defaults to window.location', () => {
const initialRoute = random.number().toString()
vi.stubGlobal('location', initialRoute)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, TIL. This will be helpful.

@stackoverfloweth stackoverfloweth merged commit feec514 into router-route Jan 7, 2024
3 checks passed
@stackoverfloweth stackoverfloweth deleted the router-route-review branch January 7, 2024 21:00
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