-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DATAP-661 update unit tests, remove snapshot tests, accessibility fix…
…es (#541) * move stuff * pill panel test * fixing pill test * update test coverage
- Loading branch information
1 parent
c9bd2a7
commit 7bb262b
Showing
11 changed files
with
148 additions
and
347 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
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
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,55 @@ | ||
import { PillPanel } from './PillPanel'; | ||
import { testRender as render, screen } from '../../testUtils/test-utils'; | ||
import { merge } from '../../testUtils/functionHelpers'; | ||
import { defaultQuery } from '../../reducers/query/query'; | ||
|
||
const renderComponent = (newQueryState) => { | ||
merge(newQueryState, defaultQuery); | ||
|
||
const data = { | ||
query: newQueryState, | ||
}; | ||
render(<PillPanel />, { | ||
preloadedState: data, | ||
}); | ||
}; | ||
describe('component: PillPanel', () => { | ||
it('renders without crashing', () => { | ||
renderComponent({ | ||
company: ['Apples', 'Bananas are great'], | ||
timely: ['Yes'], | ||
}); | ||
expect(screen.getByText('Filters applied:')).toBeInTheDocument(); | ||
expect( | ||
screen.getByRole('button', { | ||
name: /Date Received: 5\/5\/2017 - 5\/5\/2020/, | ||
}), | ||
).toBeInTheDocument(); | ||
|
||
expect( | ||
screen.getByRole('button', { | ||
name: /Apples/, | ||
}), | ||
).toBeInTheDocument(); | ||
expect( | ||
screen.getByRole('button', { | ||
name: /Bananas are great/, | ||
}), | ||
).toBeInTheDocument(); | ||
|
||
expect( | ||
screen.getByRole('button', { | ||
name: /Timely/, | ||
}), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('adds a has narrative pill', () => { | ||
renderComponent({ has_narrative: true }); | ||
expect( | ||
screen.getByRole('button', { | ||
name: /Has narrative/, | ||
}), | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
src/components/__tests__/SearchPanel.spec.js → src/components/Search/SearchPanel.spec.js
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { testRender as render, screen } from '../testUtils/test-utils'; | ||
import { TabbedNavigation } from './TabbedNavigation'; | ||
import { MODE_LIST, MODE_MAP, MODE_TRENDS } from '../constants'; | ||
import { merge } from '../testUtils/functionHelpers'; | ||
import { defaultQuery } from '../reducers/query/query'; | ||
import userEvent from '@testing-library/user-event'; | ||
import * as viewActions from '../actions/view'; | ||
|
||
const renderComponent = (tab) => { | ||
const newQueryState = { | ||
tab, | ||
}; | ||
|
||
merge(newQueryState, defaultQuery); | ||
|
||
const data = { | ||
query: newQueryState, | ||
}; | ||
render(<TabbedNavigation />, { | ||
preloadedState: data, | ||
}); | ||
}; | ||
|
||
describe('component: TabbedNavigation', () => { | ||
const user = userEvent.setup({ delay: null }); | ||
let tabChangedSpy; | ||
beforeEach(() => { | ||
tabChangedSpy = jest.spyOn(viewActions, 'tabChanged'); | ||
}); | ||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('shows the List tab', async () => { | ||
renderComponent(MODE_LIST); | ||
expect(screen.getByRole('button', { name: /Map/ })).not.toHaveClass( | ||
'active', | ||
); | ||
expect(screen.getByRole('button', { name: /List/ })).toHaveClass('active'); | ||
expect(screen.getByRole('button', { name: /Trends/ })).not.toHaveClass( | ||
'active', | ||
); | ||
|
||
await user.click(screen.getByRole('button', { name: /Map/ })); | ||
await user.click(screen.getByRole('button', { name: /List/ })); | ||
expect(tabChangedSpy).toHaveBeenCalledWith('List'); | ||
}); | ||
|
||
it('shows the Map tab', async () => { | ||
renderComponent(MODE_MAP); | ||
expect(screen.getByRole('button', { name: /Map/ })).toHaveClass('active'); | ||
expect(screen.getByRole('button', { name: /List/ })).not.toHaveClass( | ||
'active', | ||
); | ||
expect(screen.getByRole('button', { name: /Trends/ })).not.toHaveClass( | ||
'active', | ||
); | ||
|
||
// this does nothing | ||
await user.click(screen.getByRole('button', { name: /List/ })); | ||
await user.click(screen.getByRole('button', { name: /Map/ })); | ||
expect(tabChangedSpy).toHaveBeenCalledWith('Map'); | ||
}); | ||
|
||
it('shows the Trends tab', async () => { | ||
renderComponent(MODE_TRENDS); | ||
expect(screen.getByRole('button', { name: /Map/ })).not.toHaveClass( | ||
'active', | ||
); | ||
expect(screen.getByRole('button', { name: /List/ })).not.toHaveClass( | ||
'active', | ||
); | ||
expect(screen.getByRole('button', { name: /Trends/ })).toHaveClass( | ||
'active', | ||
); | ||
|
||
await user.click(screen.getByRole('button', { name: /Map/ })); | ||
await user.click(screen.getByRole('button', { name: /Trends/ })); | ||
expect(tabChangedSpy).toHaveBeenCalledWith('Trends'); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.