chore: add @vitest/eslint-plugin (#630)

This commit is contained in:
Marco Pasqualetti
2025-03-08 21:11:28 +01:00
committed by GitHub
parent 81e7af6f5e
commit da194524ee
9 changed files with 69 additions and 11 deletions
@@ -63,7 +63,7 @@ const routes = [
]
describe('buildRouteConfig works', () => {
it('Should build the correct config', () => {
it('should build the correct config', () => {
const config = buildRouteConfig(routes)
expect(config).toStrictEqual(
'PostsMyPostRoute,PostsIndexRoute,PostspostIndexRoute',
@@ -72,13 +72,15 @@ const dynamicRoute = {
}
describe('hasParentRoute works', () => {
it('Should detect parent route', () => {
it('should detect parent route', () => {
const parentRoute = hasParentRoute(routes, myPost, myPost.path)
expect(parentRoute).toStrictEqual(parent)
})
it('Should detect parent route for dynamic routes', () => {
it('should detect parent route for dynamic routes', () => {
const parentRoute = hasParentRoute(routes, dynamicRoute, dynamicRoute.path)
expect(parentRoute).toStrictEqual(parent)
})
})
@@ -108,8 +108,9 @@ const expectedSorting = [
]
describe('sortRouteNodes works', () => {
it('Should correctly sort the nodes', () => {
it('should correctly sort the nodes', () => {
const sorted = sortRouteNodes(routes)
expect(sorted).toStrictEqual(expectedSorting)
})
})
@@ -33,7 +33,7 @@ vi.mock('react-intersection-observer', () => ({
},
}))
describe('Link Component', () => {
describe('Link component', () => {
beforeEach(() => {
pushMock.mockReset()
preloadMock.mockReset()
@@ -1,5 +1,5 @@
import type { JSX } from 'react'
import { afterEach, describe, expect, test, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, render, screen } from '@testing-library/react'
@@ -51,7 +51,7 @@ vi.mock('../hooks/useServerPayloadData.ts', () => ({
describe('Test RouteMatch component', () => {
afterEach(cleanup)
test('It should correctly render nested routes', () => {
it('should correctly render nested routes', () => {
render(<RouteMatch route={route} serverInitialData={{}} />)
expect(screen.getByTestId('root')).toMatchInlineSnapshot(
@@ -1,4 +1,4 @@
import { afterEach, describe, expect, test, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup } from '@testing-library/react'
import { useRoute } from './useRoute'
@@ -21,7 +21,7 @@ describe('useRoute', () => {
useRouterContextMock.mockReset()
})
test('match routes by ids', () => {
it('should match routes by ids', () => {
useRouterContextMock.mockReturnValue({
router: {
routesById: {
@@ -36,6 +36,7 @@ describe('useRoute', () => {
},
})
/* eslint-disable vitest/max-expects */
expect(useRoute('/')?.id).toBe('/')
expect(useRoute('/not-found')?.id).toBe(undefined)
expect(useRoute('/about')?.id).toBe('/about')
@@ -50,5 +51,6 @@ describe('useRoute', () => {
expect(useRoute('/blog/catch_all/catch_all')?.id).toBe(
'/blog/[...catch_all]',
)
/* eslint-enable vitest/max-expects */
})
})