-
Notifications
You must be signed in to change notification settings - Fork 14
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 #1415 from coveo/add-uts-for-table-HOC-loading
Add uts for table hoc loading
- Loading branch information
Showing
41 changed files
with
1,125 additions
and
587 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
14 changes: 14 additions & 0 deletions
14
packages/react-vapor/src/components/loading/components/tests/ActionBarLoading.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,14 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {ActionBarLoading} from '../ActionBarLoading'; | ||
|
||
describe('ActionBarLoading tests', () => { | ||
describe('<ActionBarLoading />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<ActionBarLoading />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/react-vapor/src/components/loading/components/tests/BasicHeaderLoading.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,14 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {BasicHeaderLoading} from '../BasicHeaderLoading'; | ||
|
||
describe('BasicHeaderLoading tests', () => { | ||
describe('<BasicHeaderLoading />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<BasicHeaderLoading />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
...es/react-vapor/src/components/loading/components/tests/ContentLoadingPlaceholder.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 {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {ContentLoadingPlaceholder} from '../ContentLoadingPlaceholder'; | ||
|
||
describe('ContentLoadingPlaceholder tests', () => { | ||
describe('<ContentLoadingPlaceholder />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow( | ||
<ContentLoadingPlaceholder> | ||
<div>Test</div> | ||
</ContentLoadingPlaceholder>, | ||
{} | ||
); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/react-vapor/src/components/loading/components/tests/PaginationLoading.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,14 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {PaginationLoading} from '../PaginationLoading'; | ||
|
||
describe('PaginationLoading tests', () => { | ||
describe('<PaginationLoading />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<PaginationLoading />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
packages/react-vapor/src/components/loading/components/tests/TableLoading.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,52 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {TableLoading} from '../TableLoading'; | ||
|
||
describe('TableLoading tests', () => { | ||
describe('<TableLoading.Table />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<TableLoading.Table />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('<TableLoading.Body />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<TableLoading.Body />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
|
||
it('should render <tr/> equal of the the number of columns sent as parameter', () => { | ||
const wrapper = shallow(<TableLoading.Body numberOfRow={10} />, {}); | ||
expect(wrapper.find('tr').length).toBe(10); | ||
}); | ||
|
||
it('should render <Row/> equal of the the number of columns sent as parameter', () => { | ||
const wrapper = shallow(<TableLoading.Body numberOfColumns={8} numberOfRow={1} />, {}); | ||
expect(wrapper.find(TableLoading.Row).length).toBe(8); | ||
}); | ||
}); | ||
|
||
describe('<TableLoading.Row />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<TableLoading.Row num={0} />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
|
||
it('should add the class mod-haft if the number is odd', () => { | ||
const wrapper = shallow(<TableLoading.Row num={1} />, {}); | ||
expect(wrapper.find('div').hasClass('mod-half')).toBe(true); | ||
}); | ||
|
||
it('should not add the class mod-haft if the number is even', () => { | ||
const wrapper = shallow(<TableLoading.Row num={2} />, {}); | ||
expect(wrapper.find('div').hasClass('mod-half')).toBe(false); | ||
}); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/react-vapor/src/components/loading/components/tests/TextLoadingPlaceholder.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,36 @@ | ||
import {shallow} from 'enzyme'; | ||
import * as React from 'react'; | ||
import {TextLoadingPlaceholder} from '../TextLoadingPlaceholder'; | ||
|
||
describe('TextLoadingPlaceholder tests', () => { | ||
describe('<TextLoadingPlaceholder />', () => { | ||
it('should mount and unmount without errors', () => { | ||
expect(() => { | ||
const wrapper = shallow(<TextLoadingPlaceholder />, {}); | ||
wrapper.unmount(); | ||
}); | ||
}); | ||
|
||
it('should not have class by default', () => { | ||
const wrapper = shallow(<TextLoadingPlaceholder />, {}); | ||
expect(wrapper.hasClass('mod-small')).toBe(false); | ||
expect(wrapper.hasClass('mod-word')).toBe(false); | ||
expect(wrapper.hasClass('mod-large')).toBe(false); | ||
}); | ||
|
||
it('should add mod-small with small as prop', () => { | ||
const wrapper = shallow(<TextLoadingPlaceholder small />, {}); | ||
expect(wrapper.hasClass('mod-small')).toBe(true); | ||
}); | ||
|
||
it('should add mod-word with word as prop', () => { | ||
const wrapper = shallow(<TextLoadingPlaceholder word />, {}); | ||
expect(wrapper.hasClass('mod-word')).toBe(true); | ||
}); | ||
|
||
it('should add mod-large with large as prop', () => { | ||
const wrapper = shallow(<TextLoadingPlaceholder large />, {}); | ||
expect(wrapper.hasClass('mod-large')).toBe(true); | ||
}); | ||
}); | ||
}); |
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
35 changes: 35 additions & 0 deletions
35
packages/react-vapor/src/components/pagination/PaginationSelect.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,35 @@ | ||
import * as classNames from 'classnames'; | ||
import {FunctionComponent} from 'react'; | ||
import * as React from 'react'; | ||
|
||
export interface IPaginationSelectProps extends React.HTMLAttributes<HTMLAnchorElement> { | ||
disabled?: boolean; | ||
selected: boolean; | ||
pageNb: number; | ||
onPageClick: (pageNb: number) => void; | ||
} | ||
|
||
export const PaginationSelect: FunctionComponent<IPaginationSelectProps> = ({ | ||
disabled, | ||
selected, | ||
pageNb, | ||
onPageClick, | ||
className, | ||
...linkProps | ||
}) => ( | ||
<a | ||
{...linkProps} | ||
className={classNames( | ||
'flat-select-option', | ||
{ | ||
selectable: !selected, | ||
disabled: disabled, | ||
}, | ||
className | ||
)} | ||
data-page={pageNb} | ||
onClick={() => onPageClick(pageNb)} | ||
> | ||
{pageNb + 1} | ||
</a> | ||
); |
17 changes: 17 additions & 0 deletions
17
packages/react-vapor/src/components/pagination/PaginationSelectors.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,17 @@ | ||
import {createSelector} from 'reselect'; | ||
import * as _ from 'underscore'; | ||
import {IReactVaporState} from '../../ReactVapor'; | ||
import {IPaginationState} from '../navigation/pagination'; | ||
|
||
const getPaginationState = (state: IReactVaporState, {id}: {id: string}) => | ||
_.findWhere(state.paginationComposite, {id: id}); | ||
|
||
const getPaginationPageNumber = createSelector( | ||
getPaginationState, | ||
(paginationState: IPaginationState): number => paginationState?.pageNb ?? 0 | ||
); | ||
|
||
export const PaginationSelectors = { | ||
getPaginationState, | ||
getPaginationPageNumber, | ||
}; |
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 @@ | ||
export * from './PaginationPagesNumber'; | ||
export * from './PaginationPerPage'; | ||
export * from './PaginationSelect'; | ||
export * from './PaginationUtils'; | ||
export * from './PaginationSelectors'; | ||
export * from './TablePagination'; |
Oops, something went wrong.