-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reinstall jest and associated dependencies (#186)
- Loading branch information
1 parent
e15ffda
commit 45ccc1d
Showing
53 changed files
with
2,953 additions
and
764 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
["@babel/preset-env", { "targets": { "node": "current" } }], | ||
"@babel/preset-react" | ||
] | ||
} |
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,5 @@ | ||
import React from "react"; | ||
|
||
export function FontAwesomeIcon(props) { | ||
return <i className="fa" />; | ||
}; |
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 |
---|---|---|
@@ -1,5 +1 @@ | ||
/* eslint-disable */ | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
configure({ adapter: new Adapter() }); | ||
import "@testing-library/jest-dom"; |
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,35 +1,37 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { render, screen } from '@testing-library/react'; | ||
import DataTableDensity from '.'; | ||
|
||
describe('<DataTableDensity />', () => { | ||
const defaultWrapper = shallow( | ||
<DataTableDensity | ||
densityChange={() => () => true} | ||
/>, | ||
); | ||
|
||
const customWrapper = shallow( | ||
<DataTableDensity | ||
densityChange={() => () => true} | ||
title="Foobar" | ||
items={[ | ||
{ icon: <span>Icon </span>, text: 'first' }, | ||
{ icon: <span>Icon </span>, text: 'second' }, | ||
{ icon: <span>Icon </span>, text: 'third' }, | ||
]} | ||
/>, | ||
); | ||
beforeEach(() => { | ||
render( | ||
<DataTableDensity | ||
densityChange={() => () => true} | ||
/>, | ||
); | ||
|
||
render( | ||
<DataTableDensity | ||
densityChange={() => () => true} | ||
title="Foobar" | ||
items={[ | ||
{ icon: <span>Icon </span>, text: 'first' }, | ||
{ icon: <span>Icon </span>, text: 'second' }, | ||
{ icon: <span>Icon </span>, text: 'third' }, | ||
]} | ||
/>, | ||
); | ||
}); | ||
|
||
it('renders correct initial results', () => { | ||
expect(defaultWrapper.find('.density-buttons-title').text()).toBe('Display Density'); | ||
expect(defaultWrapper.find('.density-buttons button:first-child span').text()).toBe('expanded'); | ||
expect(defaultWrapper.find('.density-buttons button:last-child span').text()).toBe('tight'); | ||
expect(screen.getByText('Display Density')).toBeInTheDocument(); | ||
expect(screen.getByText('expanded')).toBeInTheDocument(); | ||
expect(screen.getByText('tight')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders correct custom results', () => { | ||
expect(customWrapper.find('.density-buttons-title').text()).toBe('Foobar'); | ||
expect(customWrapper.find('.density-buttons button:first-child').text()).toBe('Icon first'); | ||
expect(customWrapper.find('.density-buttons button:last-child').text()).toBe('Icon third'); | ||
expect(screen.getByText('Foobar')).toBeInTheDocument(); | ||
expect(screen.getByTitle('first')).toBeInTheDocument(); | ||
expect(screen.getByTitle('third')).toBeInTheDocument(); | ||
}); | ||
}); |
56 changes: 27 additions & 29 deletions
56
src/components/DataTable/DataTablePageResults/index.test.jsx
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,43 +1,41 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { render } from '@testing-library/react'; | ||
import DataTablePageResults from '.'; | ||
import { getByTextContent } from '../../../tests/utils'; | ||
|
||
describe('<DataTablePageResults />', () => { | ||
const defaultWrapper = shallow( | ||
<DataTablePageResults | ||
total={100} | ||
pageSize={10} | ||
currentPage={0} | ||
/>, | ||
); | ||
|
||
const customWrapper = shallow( | ||
<DataTablePageResults | ||
total={100} | ||
pageSize={10} | ||
currentPage={4} | ||
/>, | ||
); | ||
|
||
const viewingWrapper = shallow( | ||
<DataTablePageResults | ||
total={100} | ||
pageSize={10} | ||
currentPage={4} | ||
viewing | ||
/>, | ||
); | ||
|
||
it('renders correct initial results', () => { | ||
expect(defaultWrapper.find('p').text()).toBe('1 - 10 of 100 rows'); | ||
render( | ||
<DataTablePageResults | ||
total={100} | ||
pageSize={10} | ||
currentPage={0} | ||
/>, | ||
); | ||
expect(getByTextContent('1 - 10 of 100 rows')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders correct results on subsequent pages', () => { | ||
expect(customWrapper.find('p').text()).toBe('41 - 50 of 100 rows'); | ||
render( | ||
<DataTablePageResults | ||
total={100} | ||
pageSize={10} | ||
currentPage={4} | ||
/>, | ||
); | ||
expect(getByTextContent('41 - 50 of 100 rows')).toBeInTheDocument(); | ||
}); | ||
|
||
it('Correctly displays appended viewing to results list', () => { | ||
expect(viewingWrapper.find('p').text()).toBe('Viewing 41 - 50 of 100 rows'); | ||
render( | ||
<DataTablePageResults | ||
total={100} | ||
pageSize={10} | ||
currentPage={4} | ||
viewing | ||
/>, | ||
); | ||
expect(getByTextContent('Viewing 41 - 50 of 100 rows')).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
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,11 +1,11 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import '@testing-library/jest-dom'; | ||
import IconList from './index'; | ||
|
||
describe('<IconList />', () => { | ||
test('renders a default title', () => { | ||
render(<IconList component={() => (<p>text here</p>)} paneTitle="Icon List" />); | ||
render(<IconList component={() => (<p>text here</p>)} paneTitle="Icon List" items={[]}/>); | ||
expect(screen.getByRole('heading', 'Icon List')).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import '@testing-library/jest-dom'; | ||
import IconListItem from './index'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
describe('<IconListItem />', () => { | ||
test('renders a title', () => { | ||
render(<IconListItem link="http://demo.getdkan.com" title="dkan" />); | ||
render( | ||
<BrowserRouter> | ||
<IconListItem link="http://demo.getdkan.com" title="dkan" /> | ||
</BrowserRouter> | ||
); | ||
expect(screen.getByText('dkan')).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
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 |
---|---|---|
@@ -1,22 +1,35 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import '@testing-library/jest-dom'; | ||
import PublisherDatasetCountByName from './index'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
describe('<PublisherDatasetCountByName />', () => { | ||
|
||
test('If no dataset renders, just a link to the page.', () => { | ||
render(<PublisherDatasetCountByName name="Non matching organization." />); | ||
render( | ||
<BrowserRouter> | ||
<PublisherDatasetCountByName name="Non matching organization." /> | ||
</BrowserRouter> | ||
); | ||
expect(screen.getByText('datasets')).toBeInTheDocument(); | ||
}); | ||
|
||
test('If there is a publisher with datasets render the dataset count.',() => { | ||
render(<PublisherDatasetCountByName name="State Economic Council" datasetCount="3" />); | ||
render( | ||
<BrowserRouter> | ||
<PublisherDatasetCountByName name="State Economic Council" datasetCount="3" /> | ||
</BrowserRouter> | ||
); | ||
expect(screen.getByText('3 datasets')).toBeInTheDocument(); | ||
}); | ||
|
||
test('Dataset count with just one item.',() => { | ||
render(<PublisherDatasetCountByName name="State Economic Council" datasetCount="1" />); | ||
render( | ||
<BrowserRouter> | ||
<PublisherDatasetCountByName name="State Economic Council" datasetCount="1" /> | ||
</BrowserRouter> | ||
); | ||
}); | ||
|
||
}); |
Oops, something went wrong.