From f08ce19a47fe0e46e2b862dbb07465998a678191 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:41:34 -0400 Subject: [PATCH 01/14] update adjustListIfUpDir tests --- .../{adjustListIfUpDir.spec.tsx => adjustListIfUpDir.test.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/shared/ContentsTable/utils/{adjustListIfUpDir.spec.tsx => adjustListIfUpDir.test.tsx} (100%) diff --git a/src/shared/ContentsTable/utils/adjustListIfUpDir.spec.tsx b/src/shared/ContentsTable/utils/adjustListIfUpDir.test.tsx similarity index 100% rename from src/shared/ContentsTable/utils/adjustListIfUpDir.spec.tsx rename to src/shared/ContentsTable/utils/adjustListIfUpDir.test.tsx From 8ee02ed44d5db970ff7e938059cb4a34eb36f8da Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:41:49 -0400 Subject: [PATCH 02/14] update useTableDefaultSort tests --- ....spec.tsx => useTableDefaultSort.test.tsx} | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) rename src/shared/ContentsTable/useTableDefaultSort/{useTableDefaultSort.spec.tsx => useTableDefaultSort.test.tsx} (85%) diff --git a/src/shared/ContentsTable/useTableDefaultSort/useTableDefaultSort.spec.tsx b/src/shared/ContentsTable/useTableDefaultSort/useTableDefaultSort.test.tsx similarity index 85% rename from src/shared/ContentsTable/useTableDefaultSort/useTableDefaultSort.spec.tsx rename to src/shared/ContentsTable/useTableDefaultSort/useTableDefaultSort.test.tsx index 2d59b13ec6..8e079ff688 100644 --- a/src/shared/ContentsTable/useTableDefaultSort/useTableDefaultSort.spec.tsx +++ b/src/shared/ContentsTable/useTableDefaultSort/useTableDefaultSort.test.tsx @@ -2,16 +2,19 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { renderHook } from '@testing-library/react' import { MemoryRouter, Route } from 'react-router-dom' -import { useLocationParams } from 'services/navigation' - import { useTableDefaultSort } from './useTableDefaultSort' -jest.mock('services/navigation', () => ({ - ...jest.requireActual('services/navigation'), - useLocationParams: jest.fn(), +const mocks = vi.hoisted(() => ({ + useLocationParams: vi.fn(), })) -const mockedUseLocationParams = useLocationParams as jest.Mock +vi.mock('services/navigation', async () => { + const originalModule = await vi.importActual('services/navigation') + return { + ...originalModule, + useLocationParams: mocks.useLocationParams, + } +}) const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } }, @@ -29,7 +32,7 @@ describe('useTableDefaultSort', () => { describe('on initial render', () => { describe('no url parameters are set', () => { it('returns name ascending as default parameter', () => { - mockedUseLocationParams.mockReturnValue({ + mocks.useLocationParams.mockReturnValue({ params: {}, }) const { result } = renderHook(() => useTableDefaultSort(), { wrapper }) @@ -41,7 +44,7 @@ describe('useTableDefaultSort', () => { describe('url parameter is set to tree', () => { it('returns name ascending', () => { - mockedUseLocationParams.mockReturnValue({ + mocks.useLocationParams.mockReturnValue({ params: { displayType: 'tree' }, }) const { result } = renderHook(() => useTableDefaultSort(), { wrapper }) @@ -53,7 +56,7 @@ describe('useTableDefaultSort', () => { describe('url parameter is set to list', () => { it('returns misses descending', () => { - mockedUseLocationParams.mockReturnValue({ + mocks.useLocationParams.mockReturnValue({ params: { displayType: 'list' }, }) const { result } = renderHook(() => useTableDefaultSort(), { wrapper }) @@ -67,7 +70,7 @@ describe('useTableDefaultSort', () => { describe('on further renders', () => { describe('url parameter is switched to tree', () => { it('returns misses ascending', async () => { - mockedUseLocationParams + mocks.useLocationParams .mockReturnValueOnce({ params: { displayType: 'list' }, }) @@ -89,7 +92,7 @@ describe('useTableDefaultSort', () => { describe('url parameter is switched to list', () => { it('returns names descending', async () => { - mockedUseLocationParams + mocks.useLocationParams .mockReturnValueOnce({ params: { displayType: 'tree' }, }) From be2dc908055fc9a5e46570c924cdbe805dcd5019 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:42:08 -0400 Subject: [PATCH 03/14] update PullFileEntry tests to vitest --- ...eEntry.spec.tsx => PullFileEntry.test.tsx} | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) rename src/shared/ContentsTable/TableEntries/PullEntries/{PullFileEntry.spec.tsx => PullFileEntry.test.tsx} (84%) diff --git a/src/shared/ContentsTable/TableEntries/PullEntries/PullFileEntry.spec.tsx b/src/shared/ContentsTable/TableEntries/PullEntries/PullFileEntry.test.tsx similarity index 84% rename from src/shared/ContentsTable/TableEntries/PullEntries/PullFileEntry.spec.tsx rename to src/shared/ContentsTable/TableEntries/PullEntries/PullFileEntry.test.tsx index e3665df1bc..d2994d1b49 100644 --- a/src/shared/ContentsTable/TableEntries/PullEntries/PullFileEntry.spec.tsx +++ b/src/shared/ContentsTable/TableEntries/PullEntries/PullFileEntry.test.tsx @@ -1,8 +1,8 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' +import { graphql, HttpResponse } from 'msw2' +import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' import PullFileEntry from './PullFileEntry' @@ -10,30 +10,34 @@ import PullFileEntry from './PullFileEntry' import { displayTypeParameter } from '../../constants' const mockData = { - __typename: 'Repository', - commit: { - commitid: 'f00162848a3cebc0728d915763c2fd9e92132408', - flagNames: ['a', 'b'], - components: [], - coverageFile: { - isCriticalFile: true, - hashedPath: 'hashed-path', - content: - 'import pytest\nfrom path1 import index\n\ndef test_uncovered_if():\n assert index.uncovered_if() == False\n\ndef test_fully_covered():\n assert index.fully_covered() == True\n\n', - coverage: [ - { line: 1, coverage: 'H' }, - { line: 2, coverage: 'P' }, - { line: 3, coverage: 'H' }, - { line: 4, coverage: 'M' }, - { line: 5, coverage: 'H' }, - { line: 6, coverage: 'H' }, - ], - totals: { - percentCovered: 66.67, + owner: { + repository: { + __typename: 'Repository', + commit: { + commitid: 'f00162848a3cebc0728d915763c2fd9e92132408', + flagNames: ['a', 'b'], + components: [], + coverageFile: { + isCriticalFile: true, + hashedPath: 'hashed-path', + content: + 'import pytest\nfrom path1 import index\n\ndef test_uncovered_if():\n assert index.uncovered_if() == False\n\ndef test_fully_covered():\n assert index.fully_covered() == True\n\n', + coverage: [ + { line: 1, coverage: 'H' }, + { line: 2, coverage: 'P' }, + { line: 3, coverage: 'H' }, + { line: 4, coverage: 'M' }, + { line: 5, coverage: 'H' }, + { line: 6, coverage: 'H' }, + ], + totals: { + percentCovered: 66.67, + }, + }, }, + branch: null, }, }, - branch: null, } const queryClient = new QueryClient({ @@ -75,9 +79,9 @@ afterAll(() => { describe('PullFileEntry', () => { function setup() { server.use( - graphql.query('CoverageForFile', (req, res, ctx) => - res(ctx.status(200), ctx.data({ owner: { repository: mockData } })) - ) + graphql.query('CoverageForFile', (info) => { + return HttpResponse.json({ data: mockData }) + }) ) } From 5b2f0a89265796d04cdbe2e36e0ce1f8c76a17c7 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:43:11 -0400 Subject: [PATCH 04/14] update PullDirEntry tests to vitest --- .../{PullDirEntry.spec.tsx => PullDirEntry.test.tsx} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename src/shared/ContentsTable/TableEntries/PullEntries/{PullDirEntry.spec.tsx => PullDirEntry.test.tsx} (95%) diff --git a/src/shared/ContentsTable/TableEntries/PullEntries/PullDirEntry.spec.tsx b/src/shared/ContentsTable/TableEntries/PullEntries/PullDirEntry.test.tsx similarity index 95% rename from src/shared/ContentsTable/TableEntries/PullEntries/PullDirEntry.spec.tsx rename to src/shared/ContentsTable/TableEntries/PullEntries/PullDirEntry.test.tsx index 058ae6c0fc..772cf28744 100644 --- a/src/shared/ContentsTable/TableEntries/PullEntries/PullDirEntry.spec.tsx +++ b/src/shared/ContentsTable/TableEntries/PullEntries/PullDirEntry.test.tsx @@ -1,8 +1,8 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' +import { graphql, HttpResponse } from 'msw2' +import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' import PullDirEntry from './PullDirEntry' @@ -80,9 +80,9 @@ afterAll(() => { describe('PullDirEntry', () => { function setup() { server.use( - graphql.query('PullPathContents', (req, res, ctx) => - res(ctx.status(200), ctx.data(mockData)) - ) + graphql.query('PullPathContents', () => { + return HttpResponse.json({ data: mockData }) + }) ) } From 2b732909483bd4026757679730ec92b2f6dbc2e4 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:43:27 -0400 Subject: [PATCH 05/14] update CommitFileEntry tests to vitest --- ...ntry.spec.tsx => CommitFileEntry.test.tsx} | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) rename src/shared/ContentsTable/TableEntries/CommitEntries/{CommitFileEntry.spec.tsx => CommitFileEntry.test.tsx} (88%) diff --git a/src/shared/ContentsTable/TableEntries/CommitEntries/CommitFileEntry.spec.tsx b/src/shared/ContentsTable/TableEntries/CommitEntries/CommitFileEntry.test.tsx similarity index 88% rename from src/shared/ContentsTable/TableEntries/CommitEntries/CommitFileEntry.spec.tsx rename to src/shared/ContentsTable/TableEntries/CommitEntries/CommitFileEntry.test.tsx index b30ed0f16a..debef883b5 100644 --- a/src/shared/ContentsTable/TableEntries/CommitEntries/CommitFileEntry.spec.tsx +++ b/src/shared/ContentsTable/TableEntries/CommitEntries/CommitFileEntry.test.tsx @@ -1,8 +1,8 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' +import { graphql, HttpResponse } from 'msw2' +import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' import CommitFileEntry from './CommitFileEntry' @@ -10,30 +10,34 @@ import CommitFileEntry from './CommitFileEntry' import { displayTypeParameter } from '../../constants' const mockData = { - __typename: 'Repository', - commit: { - commitid: 'f00162848a3cebc0728d915763c2fd9e92132408', - flagNames: ['a', 'b'], - components: [], - coverageFile: { - isCriticalFile: true, - hashedPath: 'hashed-path', - content: - 'import pytest\nfrom path1 import index\n\ndef test_uncovered_if():\n assert index.uncovered_if() == False\n\ndef test_fully_covered():\n assert index.fully_covered() == True\n\n', - coverage: [ - { line: 1, coverage: 'H' }, - { line: 2, coverage: 'P' }, - { line: 4, coverage: 'H' }, - { line: 5, coverage: 'M' }, - { line: 7, coverage: 'H' }, - { line: 8, coverage: 'H' }, - ], - totals: { - percentCovered: 66.67, + owner: { + repository: { + __typename: 'Repository', + commit: { + commitid: 'f00162848a3cebc0728d915763c2fd9e92132408', + flagNames: ['a', 'b'], + components: [], + coverageFile: { + isCriticalFile: true, + hashedPath: 'hashed-path', + content: + 'import pytest\nfrom path1 import index\n\ndef test_uncovered_if():\n assert index.uncovered_if() == False\n\ndef test_fully_covered():\n assert index.fully_covered() == True\n\n', + coverage: [ + { line: 1, coverage: 'H' }, + { line: 2, coverage: 'P' }, + { line: 4, coverage: 'H' }, + { line: 5, coverage: 'M' }, + { line: 7, coverage: 'H' }, + { line: 8, coverage: 'H' }, + ], + totals: { + percentCovered: 66.67, + }, + }, }, + branch: null, }, }, - branch: null, } const queryClient = new QueryClient({ @@ -67,16 +71,13 @@ afterAll(() => { describe('CommitFileEntry', () => { function setup() { const user = userEvent.setup() - const mockVars = jest.fn() + const mockVars = vi.fn() server.use( - graphql.query('CoverageForFile', (req, res, ctx) => { - mockVars(req.variables) + graphql.query('CoverageForFile', (info) => { + mockVars(info.variables) - return res( - ctx.status(200), - ctx.data({ owner: { repository: mockData } }) - ) + return HttpResponse.json({ data: mockData }) }) ) From ed1e09b853312f9189aebb2ed3e8f15acfa199b6 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:43:42 -0400 Subject: [PATCH 06/14] update CommitDirEntry tests to vitest --- ...CommitDirEntry.spec.tsx => CommitDirEntry.test.tsx} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename src/shared/ContentsTable/TableEntries/CommitEntries/{CommitDirEntry.spec.tsx => CommitDirEntry.test.tsx} (96%) diff --git a/src/shared/ContentsTable/TableEntries/CommitEntries/CommitDirEntry.spec.tsx b/src/shared/ContentsTable/TableEntries/CommitEntries/CommitDirEntry.test.tsx similarity index 96% rename from src/shared/ContentsTable/TableEntries/CommitEntries/CommitDirEntry.spec.tsx rename to src/shared/ContentsTable/TableEntries/CommitEntries/CommitDirEntry.test.tsx index 1796e0b2a3..cc132992c8 100644 --- a/src/shared/ContentsTable/TableEntries/CommitEntries/CommitDirEntry.spec.tsx +++ b/src/shared/ContentsTable/TableEntries/CommitEntries/CommitDirEntry.test.tsx @@ -1,8 +1,8 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' +import { graphql, HttpResponse } from 'msw2' +import { setupServer } from 'msw2/node' import qs from 'qs' import { MemoryRouter, Route } from 'react-router-dom' @@ -72,9 +72,9 @@ afterAll(() => { describe('CommitDirEntry', () => { function setup() { server.use( - graphql.query('CommitPathContents', (req, res, ctx) => - res(ctx.status(200), ctx.data(mockData)) - ) + graphql.query('CommitPathContents', (info) => { + return HttpResponse.json({ data: mockData }) + }) ) } From dd08accc4cb9230b5acf4669e746a51828134b32 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:43:56 -0400 Subject: [PATCH 07/14] update BranchFileEntry tests to vitest --- ...chFileEntry.spec.jsx => BranchFileEntry.test.jsx} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename src/shared/ContentsTable/TableEntries/BranchEntries/{BranchFileEntry.spec.jsx => BranchFileEntry.test.jsx} (97%) diff --git a/src/shared/ContentsTable/TableEntries/BranchEntries/BranchFileEntry.spec.jsx b/src/shared/ContentsTable/TableEntries/BranchEntries/BranchFileEntry.test.jsx similarity index 97% rename from src/shared/ContentsTable/TableEntries/BranchEntries/BranchFileEntry.spec.jsx rename to src/shared/ContentsTable/TableEntries/BranchEntries/BranchFileEntry.test.jsx index 78c19c30e9..df8897b255 100644 --- a/src/shared/ContentsTable/TableEntries/BranchEntries/BranchFileEntry.spec.jsx +++ b/src/shared/ContentsTable/TableEntries/BranchEntries/BranchFileEntry.test.jsx @@ -1,8 +1,8 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' +import { graphql, HttpResponse } from 'msw2' +import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' import BranchFileEntry from './BranchFileEntry' @@ -82,13 +82,13 @@ afterAll(() => { describe('BranchFileEntry', () => { function setup() { const user = userEvent.setup() - const mockVars = jest.fn() + const mockVars = vi.fn() server.use( - graphql.query('CoverageForFile', (req, res, ctx) => { - mockVars(req.variables) + graphql.query('CoverageForFile', (info) => { + mockVars(info.variables) - return res(ctx.status(200), ctx.data(mockData)) + return HttpResponse.json({ data: mockData }) }) ) From a9f5549a456bd44489a642e46b6a1e14244f30a5 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:44:10 -0400 Subject: [PATCH 08/14] update BranchDirEntry tests to vitest --- ...BranchDirEntry.spec.jsx => BranchDirEntry.test.jsx} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename src/shared/ContentsTable/TableEntries/BranchEntries/{BranchDirEntry.spec.jsx => BranchDirEntry.test.jsx} (95%) diff --git a/src/shared/ContentsTable/TableEntries/BranchEntries/BranchDirEntry.spec.jsx b/src/shared/ContentsTable/TableEntries/BranchEntries/BranchDirEntry.test.jsx similarity index 95% rename from src/shared/ContentsTable/TableEntries/BranchEntries/BranchDirEntry.spec.jsx rename to src/shared/ContentsTable/TableEntries/BranchEntries/BranchDirEntry.test.jsx index 83d3634303..2f08d425fb 100644 --- a/src/shared/ContentsTable/TableEntries/BranchEntries/BranchDirEntry.spec.jsx +++ b/src/shared/ContentsTable/TableEntries/BranchEntries/BranchDirEntry.test.jsx @@ -1,8 +1,8 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' -import { graphql } from 'msw' -import { setupServer } from 'msw/node' +import { graphql, HttpResponse } from 'msw2' +import { setupServer } from 'msw2/node' import { MemoryRouter, Route } from 'react-router-dom' import BranchDirEntry from './BranchDirEntry' @@ -70,9 +70,9 @@ describe('BranchDirEntry', () => { const user = userEvent.setup() server.use( - graphql.query('BranchContents', (req, res, ctx) => - res(ctx.status(200), ctx.data(mockData)) - ) + graphql.query('BranchContents', (info) => { + return HttpResponse.json({ data: mockData }) + }) ) return { user } From a9a8a37f90c8ad56db6e43ff09b6659b36687207 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:44:28 -0400 Subject: [PATCH 09/14] update FileEntry tests to vitest --- .../{FileEntry.spec.jsx => FileEntry.test.jsx} | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename src/shared/ContentsTable/TableEntries/BaseEntries/{FileEntry.spec.jsx => FileEntry.test.jsx} (93%) diff --git a/src/shared/ContentsTable/TableEntries/BaseEntries/FileEntry.spec.jsx b/src/shared/ContentsTable/TableEntries/BaseEntries/FileEntry.test.jsx similarity index 93% rename from src/shared/ContentsTable/TableEntries/BaseEntries/FileEntry.spec.jsx rename to src/shared/ContentsTable/TableEntries/BaseEntries/FileEntry.test.jsx index 90ea138cee..a1b8471e26 100644 --- a/src/shared/ContentsTable/TableEntries/BaseEntries/FileEntry.spec.jsx +++ b/src/shared/ContentsTable/TableEntries/BaseEntries/FileEntry.test.jsx @@ -15,7 +15,7 @@ const wrapper = ({ children }) => ( describe('FileEntry', () => { describe('checking properties on list display', () => { it('displays the file path', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { describe('checking properties on tree display', () => { it('displays the file name', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { }) it('does not display the file name', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { describe('file is a critical file', () => { it('displays critical file label', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { describe('is displaying a list', () => { it('displays the file path label', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { describe('prefetches data', () => { it('fires the prefetch function on hover', async () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() const user = userEvent.setup() render( { }) describe('passed pageName commit props', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() it('sets the correct href', () => { render( { describe('passed queryParams prop', () => { it('sets the correct href', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( Date: Mon, 23 Sep 2024 16:44:43 -0400 Subject: [PATCH 10/14] update DirEntry tests to vitest --- .../{DirEntry.spec.jsx => DirEntry.test.jsx} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename src/shared/ContentsTable/TableEntries/BaseEntries/{DirEntry.spec.jsx => DirEntry.test.jsx} (92%) diff --git a/src/shared/ContentsTable/TableEntries/BaseEntries/DirEntry.spec.jsx b/src/shared/ContentsTable/TableEntries/BaseEntries/DirEntry.test.jsx similarity index 92% rename from src/shared/ContentsTable/TableEntries/BaseEntries/DirEntry.spec.jsx rename to src/shared/ContentsTable/TableEntries/BaseEntries/DirEntry.test.jsx index f5a9312ccf..32d5f65a03 100644 --- a/src/shared/ContentsTable/TableEntries/BaseEntries/DirEntry.spec.jsx +++ b/src/shared/ContentsTable/TableEntries/BaseEntries/DirEntry.test.jsx @@ -12,7 +12,7 @@ const wrapper = ({ children }) => ( describe('DirEntry', () => { it('displays the directory name', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { describe('path is given', () => { it('sets the correct href', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { describe('no path is given', () => { it('sets the correct href', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( , { wrapper } @@ -63,7 +63,7 @@ describe('DirEntry', () => { describe('query params value is passed', () => { it('sets the correct href', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { it('fires the prefetch function on hover', async () => { const user = userEvent.setup() - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( { describe('pageName prop is passed', () => { it('sets the correct href', () => { - const runPrefetchMock = jest.fn() + const runPrefetchMock = vi.fn() render( Date: Mon, 23 Sep 2024 16:44:58 -0400 Subject: [PATCH 11/14] update MissingFileData tests to vitest --- .../{MissingFileData.spec.tsx => MissingFileData.test.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/shared/ContentsTable/MissingFileData/{MissingFileData.spec.tsx => MissingFileData.test.tsx} (100%) diff --git a/src/shared/ContentsTable/MissingFileData/MissingFileData.spec.tsx b/src/shared/ContentsTable/MissingFileData/MissingFileData.test.tsx similarity index 100% rename from src/shared/ContentsTable/MissingFileData/MissingFileData.spec.tsx rename to src/shared/ContentsTable/MissingFileData/MissingFileData.test.tsx From 8fa9bbad711c85e99ff4d0613ec7685e903755bf Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:45:15 -0400 Subject: [PATCH 12/14] update FileBreadcrumb tests to vitest --- ...crumb.spec.jsx => FileBreadcrumb.test.jsx} | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) rename src/shared/ContentsTable/FileBreadcrumb/{FileBreadcrumb.spec.jsx => FileBreadcrumb.test.jsx} (62%) diff --git a/src/shared/ContentsTable/FileBreadcrumb/FileBreadcrumb.spec.jsx b/src/shared/ContentsTable/FileBreadcrumb/FileBreadcrumb.test.jsx similarity index 62% rename from src/shared/ContentsTable/FileBreadcrumb/FileBreadcrumb.spec.jsx rename to src/shared/ContentsTable/FileBreadcrumb/FileBreadcrumb.test.jsx index e8e6f52037..a6d69beef5 100644 --- a/src/shared/ContentsTable/FileBreadcrumb/FileBreadcrumb.spec.jsx +++ b/src/shared/ContentsTable/FileBreadcrumb/FileBreadcrumb.test.jsx @@ -1,6 +1,5 @@ -import { render, screen } from 'custom-testing-library' - import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { render, screen } from '@testing-library/react' import { MemoryRouter, Route } from 'react-router-dom' import FileBreadcrumb from './FileBreadcrumb' @@ -13,28 +12,21 @@ const queryClient = new QueryClient({ }, }) -describe('FileBreadcrumb', () => { - function setup({ entries, path }) { - render( - - - - - - - - ) - } +const wrapper = ({ children }) => ( + + + + {children} + + + +) +describe('FileBreadcrumb', () => { describe('path is provided in route', () => { - beforeEach(() => { - setup({ - entries: ['/gh/owner/coolrepo/tree/main/src/tests'], - path: '/:provider/:owner/:repo/tree/:branch/:path+', - }) - }) - it('renders the breadcrumb', () => { + render(, { wrapper }) + const repo = screen.getByRole('link', { name: 'coolrepo' }) expect(repo).toBeInTheDocument() expect(repo).toHaveAttribute('href', '/gh/owner/coolrepo/tree/main/') From fc63f6291f58d936070d36d124150fb915b19a0c Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:45:33 -0400 Subject: [PATCH 13/14] update DisplayTypeButton tests to vitest --- ...utton.spec.jsx => DisplayTypeButton.test.jsx} | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) rename src/shared/ContentsTable/DisplayTypeButton/{DisplayTypeButton.spec.jsx => DisplayTypeButton.test.jsx} (94%) diff --git a/src/shared/ContentsTable/DisplayTypeButton/DisplayTypeButton.spec.jsx b/src/shared/ContentsTable/DisplayTypeButton/DisplayTypeButton.test.jsx similarity index 94% rename from src/shared/ContentsTable/DisplayTypeButton/DisplayTypeButton.spec.jsx rename to src/shared/ContentsTable/DisplayTypeButton/DisplayTypeButton.test.jsx index bca5b3b02d..68ab5844ef 100644 --- a/src/shared/ContentsTable/DisplayTypeButton/DisplayTypeButton.spec.jsx +++ b/src/shared/ContentsTable/DisplayTypeButton/DisplayTypeButton.test.jsx @@ -1,16 +1,18 @@ -import { render, screen } from 'custom-testing-library' - import { QueryClient, QueryClientProvider } from '@tanstack/react-query' +import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { useLocationParams } from 'services/navigation' import DisplayTypeButton from './DisplayTypeButton' -jest.mock('services/navigation', () => ({ - ...jest.requireActual('services/navigation'), - useLocationParams: jest.fn(), -})) +vi.mock('services/navigation', () => { + const originalModule = vi.importActual('services/navigation') + return { + ...originalModule, + useLocationParams: vi.fn(), + } +}) const queryClient = new QueryClient({ defaultOptions: { @@ -53,7 +55,7 @@ describe('Coverage Tab', () => { function setup(urlParams = mockUrlParams) { const user = userEvent.setup() useLocationParams.mockReturnValue({ - updateParams: jest.fn(), + updateParams: vi.fn(), params: urlParams, }) From 66aa9db45ea496e8e837bc1204db6dc7443e6640 Mon Sep 17 00:00:00 2001 From: nicholas-codecov Date: Mon, 23 Sep 2024 16:46:49 -0400 Subject: [PATCH 14/14] update ContentsTableHeader tests to vitest --- .../ContentsTableHeader.spec.jsx | 33 ------------------- .../ContentsTableHeader.test.jsx | 26 +++++++++++++++ 2 files changed, 26 insertions(+), 33 deletions(-) delete mode 100644 src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.spec.jsx create mode 100644 src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.test.jsx diff --git a/src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.spec.jsx b/src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.spec.jsx deleted file mode 100644 index 42169e1687..0000000000 --- a/src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.spec.jsx +++ /dev/null @@ -1,33 +0,0 @@ -import { render, screen } from 'custom-testing-library' - -import { MemoryRouter, Route } from 'react-router-dom' - -import ContentsTableHeader from './ContentsTableHeader' - -describe('ContentsTableHeader', () => { - function setup({ entries, path }) { - render( - - - -

Hello World

-
-
-
- ) - } - - describe('path is provided in route', () => { - beforeEach(() => { - setup({ - entries: ['/gh/owner/coolrepo/tree/main/src/tests'], - path: '/:provider/:owner/:repo/tree/:branch/:path+', - }) - }) - - it('renders the child', () => { - const wrappingDiv = screen.getByText('Hello World') - expect(wrappingDiv).toBeInTheDocument() - }) - }) -}) diff --git a/src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.test.jsx b/src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.test.jsx new file mode 100644 index 0000000000..5be1e158fb --- /dev/null +++ b/src/shared/ContentsTable/ContentsTableHeader/ContentsTableHeader.test.jsx @@ -0,0 +1,26 @@ +import { render, screen } from '@testing-library/react' +import { MemoryRouter, Route } from 'react-router-dom' + +import ContentsTableHeader from './ContentsTableHeader' + +const wrapper = ({ children }) => ( + + {children} + +) + +describe('ContentsTableHeader', () => { + describe('path is provided in route', () => { + it('renders the child', () => { + render( + +

Hello World

+
, + { wrapper } + ) + + const wrappingDiv = screen.getByText('Hello World') + expect(wrappingDiv).toBeInTheDocument() + }) + }) +})