generated from the-collab-lab/smart-shopping-list
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from the-collab-lab/update-tests-from-list-vie…
…w-refactor-66 Reimplementation of managelist tests on list view.
- Loading branch information
Showing
2 changed files
with
63 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,54 @@ | ||
// import { render, screen } from '@testing-library/react'; | ||
// import { List } from '../../../src/views'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { List } from '../../../src/views'; | ||
import { vi } from 'vitest'; | ||
// import { QueryClientProvider } from 'react-query'; | ||
// import { queryClient } from '../../../src/App'; | ||
|
||
// describe('List', () => { | ||
// afterEach(() => { | ||
// vi.resetAllMocks(); | ||
// vi.clearAllMocks(); | ||
// }); | ||
|
||
// const renderList = ({ listPath, data }) => { | ||
// return render( | ||
// <QueryClientProvider client={queryClient}> | ||
// <List listPath={listPath} data={data} /> | ||
// </QueryClientProvider>, | ||
// ); | ||
// }; | ||
|
||
// it('renders AddItemForm and ShareForm if listPath is passed in', async () => { | ||
// const data = { data: [{ name: 'apple' }], loading: false }; | ||
// renderList({ listPath: '/test-list', data }); | ||
|
||
// const addItemForm = screen.queryByTestId('addItemForm-header'); | ||
// const shareForm = screen.queryByTestId('shareForm-header'); | ||
// expect(addItemForm).toBeInTheDocument(); | ||
// expect(shareForm).toBeInTheDocument(); | ||
|
||
// const noListPathMessage = screen.queryByTestId('no-listpath-span'); | ||
// expect(noListPathMessage).toBeFalsy(); | ||
// }); | ||
// it('does not render AddItemForm and ShareForm if listPath is not passed in', async () => { | ||
// renderList({}); | ||
|
||
// const addItemForm = screen.queryByTestId('addItemForm-header'); | ||
// const shareForm = screen.queryByTestId('shareForm-header'); | ||
// expect(addItemForm).not.toBeInTheDocument(); | ||
// expect(shareForm).not.toBeInTheDocument(); | ||
|
||
// const noListPathMessage = screen.queryByTestId('no-listpath-span'); | ||
// expect(noListPathMessage).toBeTruthy(); | ||
// }); | ||
// }); | ||
|
||
test.skip('List', () => { | ||
return null; | ||
import { QueryClientProvider } from 'react-query'; | ||
import { queryClient } from '../../../src/App'; | ||
|
||
describe('List', () => { | ||
afterEach(() => { | ||
vi.resetAllMocks(); | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
const renderList = ({ listPath, data }) => { | ||
return render( | ||
<QueryClientProvider client={queryClient}> | ||
<List listPath={listPath} data={data} /> | ||
</QueryClientProvider>, | ||
); | ||
}; | ||
|
||
it('renders AddItemForm and ShareForm if listPath is passed in', async () => { | ||
const data = { data: [{ name: 'apple' }], loading: false }; | ||
renderList({ listPath: '/test-list', data }); | ||
|
||
const addItemForm = screen.queryByTestId('addItemForm-header'); | ||
const shareForm = screen.queryByTestId('shareForm-header'); | ||
expect(addItemForm).toBeInTheDocument(); | ||
expect(shareForm).toBeInTheDocument(); | ||
|
||
const noListPathMessage = screen.queryByTestId('no-listpath-span'); | ||
expect(noListPathMessage).toBeFalsy(); | ||
}); | ||
|
||
it('renders error message when listPath is not passed in', async () => { | ||
const data = { data: [] }; | ||
renderList({ listPath: '', data }); | ||
|
||
const addItemForm = screen.queryByTestId('addItemForm-header'); | ||
const shareForm = screen.queryByTestId('shareForm-header'); | ||
const errorMessage = screen.getByTestId('noListErrorMsg'); | ||
|
||
expect(errorMessage).toBeInTheDocument(); | ||
expect(addItemForm).not.toBeInTheDocument(); | ||
expect(shareForm).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('renders error message when items are not passed in', async () => { | ||
const data = { data: [] }; | ||
renderList({ listPath: '/test-list', data }); | ||
const errorMessage = screen.getByTestId('noItemsErrorMsg'); | ||
|
||
expect(errorMessage).toBeInTheDocument(); | ||
}); | ||
}); |