-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(tests): another portion of tests (#1010)
- Loading branch information
1 parent
657db0b
commit 47d524c
Showing
21 changed files
with
194 additions
and
10 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
File renamed without changes.
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
File renamed without changes.
47 changes: 47 additions & 0 deletions
47
features/proposal/components/VoterDetailsCard/tests/VoterDetailsCard.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { render } from 'jest/testUtils'; | ||
|
||
import { VoterDetailsCard } from 'features/proposal/components/VoterDetailsCard'; | ||
|
||
jest.mock('components/Icon', () => { | ||
return { | ||
Icon: ({ name }: { name: string }) => <div>{name}</div>, | ||
}; | ||
}); | ||
|
||
describe('VoterDetailsCard', () => { | ||
// it('Should render component', () => { | ||
// const name = 'Hello World!'; | ||
// | ||
// const { getByText } = render( | ||
// <VoterDetailsCard | ||
// vote="Yes" | ||
// name="Hello World!" | ||
// transactionHash="123" | ||
// timestamp={null} | ||
// groups={['GR1', 'GR2']} | ||
// /> | ||
// ); | ||
// | ||
// expect(getByText(name)).toBeInTheDocument(); | ||
// }); | ||
|
||
it.each` | ||
vote | icon | ||
${'Yes'} | ${'votingYes'} | ||
${'No'} | ${'votingNo'} | ||
${'Dismiss'} | ${'votingDismissAlt'} | ||
${'Other'} | ${'notVoted'} | ||
`('Should render proper icon for $vote vote', ({ vote, icon }) => { | ||
const { getByText } = render( | ||
<VoterDetailsCard | ||
vote={vote} | ||
name="Hello World!" | ||
transactionHash="123" | ||
timestamp={null} | ||
groups={['GR1', 'GR2']} | ||
/> | ||
); | ||
|
||
expect(getByText(icon)).toBeInTheDocument(); | ||
}); | ||
}); |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...sal/components/voters-list/VotersList.tsx → ...osal/components/VotersList/VotersList.tsx
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
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
features/proposal/components/VotersList/tests/VotersList.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { render } from 'jest/testUtils'; | ||
|
||
import { VoterDetail } from 'features/types'; | ||
|
||
import { VotersList } from 'features/proposal/components/VotersList'; | ||
|
||
describe('VotersList', () => { | ||
it('Should render "No data" state', () => { | ||
const { getByText } = render(<VotersList data={[]} />); | ||
|
||
expect(getByText('No votes here')).toBeInTheDocument(); | ||
}); | ||
|
||
it('Should render component', () => { | ||
const data = [ | ||
{ | ||
name: 'N1', | ||
vote: 'Yes', | ||
}, | ||
{ | ||
name: 'N2', | ||
vote: 'No', | ||
}, | ||
] as VoterDetail[]; | ||
|
||
const { getByText } = render(<VotersList data={data} />); | ||
|
||
expect(getByText('N1')).toBeInTheDocument(); | ||
expect(getByText('N2')).toBeInTheDocument(); | ||
}); | ||
}); |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
86 changes: 86 additions & 0 deletions
86
features/search/search-results/components/MembersTabView/tests/MembersTabView.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
|
||
import { render } from 'jest/testUtils'; | ||
import { fireEvent } from '@testing-library/dom'; | ||
|
||
import { useModal } from 'components/modal'; | ||
import { useSearchResults } from 'features/search/search-results/SearchResults'; | ||
|
||
import { MembersTabView } from 'features/search/search-results/components/MembersTabView'; | ||
|
||
jest.mock('react-text-truncate', () => { | ||
return ({ text }: { text: string }) => <div>{text}</div>; | ||
}); | ||
|
||
jest.mock('components/modal', () => { | ||
return { | ||
useModal: jest.fn(() => []), | ||
}; | ||
}); | ||
|
||
jest.mock('features/search/search-results/SearchResults', () => { | ||
return { | ||
useSearchResults: jest.fn(() => ({})), | ||
}; | ||
}); | ||
|
||
describe('MembersTabView', () => { | ||
it('Should "No Data" state', () => { | ||
const { getByText } = render(<MembersTabView />); | ||
|
||
expect( | ||
getByText("We couldn't find anything matching your search.", { | ||
exact: false, | ||
}) | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('Should render component', () => { | ||
const name = 'My Name Is'; | ||
|
||
// @ts-ignore | ||
useSearchResults.mockImplementation(() => ({ | ||
searchResults: { | ||
members: [ | ||
{ | ||
id: 'N1', | ||
name, | ||
groups: ['MEW holders'], | ||
votes: 0, | ||
}, | ||
], | ||
}, | ||
})); | ||
|
||
const { getByText } = render(<MembersTabView />); | ||
|
||
expect(getByText(name)).toBeInTheDocument(); | ||
}); | ||
|
||
it('Should show modal', () => { | ||
const showModal = jest.fn(); | ||
|
||
// @ts-ignore | ||
useModal.mockImplementation(() => [showModal]); | ||
|
||
// @ts-ignore | ||
useSearchResults.mockImplementation(() => ({ | ||
searchResults: { | ||
members: [ | ||
{ | ||
id: 'N1', | ||
name: 'N1', | ||
groups: ['MEW holders'], | ||
votes: 0, | ||
}, | ||
], | ||
}, | ||
})); | ||
|
||
const { getAllByRole } = render(<MembersTabView />); | ||
|
||
fireEvent.click(getAllByRole('button')[0]); | ||
|
||
expect(showModal).toBeCalled(); | ||
}); | ||
}); |
File renamed without changes.
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
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
...s/search/search-results/components/NoSearchResultsView/tests/NoSearchResultsView.spec.tsx
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { render } from 'jest/testUtils'; | ||
|
||
import { NoSearchResultsView } from 'features/search/search-results/components/NoSearchResultsView'; | ||
|
||
describe('NoSearchResultsView', () => { | ||
it('Should render "No results"', () => { | ||
const { getByText } = render(<NoSearchResultsView />); | ||
|
||
expect(getByText('No results')).toBeInTheDocument(); | ||
}); | ||
|
||
it('Should render "No results" with query', () => { | ||
const query = 'Hello World!'; | ||
|
||
const { getByText } = render(<NoSearchResultsView query={query} />); | ||
|
||
expect(getByText(`No results for ${query}`)).toBeInTheDocument(); | ||
}); | ||
}); |
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