@dhis2-ui/table 10.16.2 → 10.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/data-table/__tests__/data-table-cell.test.js +168 -0
- package/src/data-table/__tests__/data-table-column-header/filter-handle.test.js +43 -0
- package/src/data-table/__tests__/data-table-column-header/sorter.test.js +41 -0
- package/src/data-table/__tests__/data-table-column-header.test.js +227 -0
- package/src/data-table/__tests__/data-table-row/expand-handle-cell.js +32 -0
- package/src/data-table/__tests__/data-table-row/expanded-row.test.js +57 -0
- package/src/data-table/__tests__/data-table-row.test.js +162 -0
- package/src/data-table/__tests__/data-table.test.js +85 -0
- package/src/data-table/data-table-body.js +3 -0
- package/src/data-table/data-table-cell.js +111 -0
- package/src/data-table/data-table-column-header/data-table-column-header.js +130 -0
- package/src/data-table/data-table-column-header/data-table-column-header.styles.js +30 -0
- package/src/data-table/data-table-column-header/filter-handle.js +30 -0
- package/src/data-table/data-table-column-header/sorter.js +67 -0
- package/src/data-table/data-table-foot.js +3 -0
- package/src/data-table/data-table-head.js +3 -0
- package/src/data-table/data-table-row/data-table-row.js +103 -0
- package/src/data-table/data-table-row/data-table-row.styles.js +20 -0
- package/src/data-table/data-table-row/drag-handle-cell.js +9 -0
- package/src/data-table/data-table-row/expand-handle-cell.js +28 -0
- package/src/data-table/data-table-row/expanded-row.js +51 -0
- package/src/data-table/data-table-toolbar.js +3 -0
- package/src/data-table/data-table.e2e.stories.js +192 -0
- package/src/data-table/data-table.js +75 -0
- package/src/data-table/data-table.prod.stories.js +1342 -0
- package/src/data-table/features/can_scroll/index.js +48 -0
- package/src/data-table/features/can_scroll.feature +31 -0
- package/src/data-table/index.js +8 -0
- package/src/data-table/table-elements/__tests__/table-body.test.js +40 -0
- package/src/data-table/table-elements/__tests__/table-data-cell.test.js +123 -0
- package/src/data-table/table-elements/__tests__/table-foot.test.js +40 -0
- package/src/data-table/table-elements/__tests__/table-head.test.js +40 -0
- package/src/data-table/table-elements/__tests__/table-header-cell-action.test.js +46 -0
- package/src/data-table/table-elements/__tests__/table-header-cell.test.js +130 -0
- package/src/data-table/table-elements/__tests__/table-row.test.js +52 -0
- package/src/data-table/table-elements/__tests__/table-scroll-box.test.js +40 -0
- package/src/data-table/table-elements/__tests__/table-toolbar.test.js +44 -0
- package/src/data-table/table-elements/__tests__/table.test.js +53 -0
- package/src/data-table/table-elements/features/can_scroll/index.js +42 -0
- package/src/data-table/table-elements/features/can_scroll.feature +31 -0
- package/src/data-table/table-elements/index.js +10 -0
- package/src/data-table/table-elements/table-body.js +75 -0
- package/src/data-table/table-elements/table-data-cell/table-data-cell.js +126 -0
- package/src/data-table/table-elements/table-data-cell/table-data-cell.styles.js +42 -0
- package/src/data-table/table-elements/table-foot.js +35 -0
- package/src/data-table/table-elements/table-head.js +26 -0
- package/src/data-table/table-elements/table-header-cell/table-header-cell.js +121 -0
- package/src/data-table/table-elements/table-header-cell/table-header-cell.styles.js +71 -0
- package/src/data-table/table-elements/table-header-cell-action.js +62 -0
- package/src/data-table/table-elements/table-row.js +52 -0
- package/src/data-table/table-elements/table-scroll-box.js +41 -0
- package/src/data-table/table-elements/table-toolbar.js +50 -0
- package/src/data-table/table-elements/table.e2e.stories.js +190 -0
- package/src/data-table/table-elements/table.js +70 -0
- package/src/data-table/table-elements/table.stories.internal.js +1144 -0
- package/src/index.js +32 -0
- package/src/locales/ar/translations.json +4 -0
- package/src/locales/cs/translations.json +4 -0
- package/src/locales/en/translations.json +4 -0
- package/src/locales/es/translations.json +4 -0
- package/src/locales/es_419/translations.json +4 -0
- package/src/locales/fr/translations.json +4 -0
- package/src/locales/index.js +44 -0
- package/src/locales/km/translations.json +4 -0
- package/src/locales/lo/translations.json +4 -0
- package/src/locales/nb/translations.json +4 -0
- package/src/locales/nl/translations.json +4 -0
- package/src/locales/pt/translations.json +4 -0
- package/src/locales/ru/translations.json +4 -0
- package/src/locales/uk/translations.json +4 -0
- package/src/locales/uz_UZ_Cyrl/translations.json +4 -0
- package/src/locales/zh/translations.json +4 -0
- package/src/stacked-table/add-col-num-to-children.js +16 -0
- package/src/stacked-table/content-with-title.js +40 -0
- package/src/stacked-table/extract-header-labels.js +99 -0
- package/src/stacked-table/index.js +8 -0
- package/src/stacked-table/stacked-table-body.js +23 -0
- package/src/stacked-table/stacked-table-cell-head.js +39 -0
- package/src/stacked-table/stacked-table-cell.js +60 -0
- package/src/stacked-table/stacked-table-foot.js +24 -0
- package/src/stacked-table/stacked-table-head.js +23 -0
- package/src/stacked-table/stacked-table-row-head.js +19 -0
- package/src/stacked-table/stacked-table-row.js +50 -0
- package/src/stacked-table/stacked-table.js +33 -0
- package/src/stacked-table/stacked-table.prod.stories.js +463 -0
- package/src/stacked-table/stacked-table.test.js +127 -0
- package/src/stacked-table/supply-header-labels-to-children.js +7 -0
- package/src/stacked-table/table-context.js +4 -0
- package/src/stacked-table/table.js +28 -0
- package/src/table/index.js +8 -0
- package/src/table/table-body.js +21 -0
- package/src/table/table-cell-head.js +56 -0
- package/src/table/table-cell.js +56 -0
- package/src/table/table-context.js +7 -0
- package/src/table/table-foot.js +21 -0
- package/src/table/table-head.js +21 -0
- package/src/table/table-row-head.js +30 -0
- package/src/table/table-row.js +51 -0
- package/src/table/table.js +41 -0
- package/src/table/table.prod.stories.js +724 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'
|
|
2
|
+
|
|
3
|
+
Given('a scrolling datatable is rendered', () => {
|
|
4
|
+
cy.visitStory('DataTable', 'Fixed Header And Columns')
|
|
5
|
+
})
|
|
6
|
+
When('the user scrolls down', () => {
|
|
7
|
+
cy.get('[data-test="dhis2-uicore-datatable-scrollbox"]').scrollTo(
|
|
8
|
+
'bottomLeft'
|
|
9
|
+
)
|
|
10
|
+
})
|
|
11
|
+
When('the user scrolls right', () => {
|
|
12
|
+
cy.get('[data-test="dhis2-uicore-datatable-scrollbox"]').scrollTo(
|
|
13
|
+
'topRight'
|
|
14
|
+
)
|
|
15
|
+
})
|
|
16
|
+
When('the user scrolls down and right', () => {
|
|
17
|
+
cy.get('[data-test="dhis2-uicore-datatable-scrollbox"]').scrollTo(
|
|
18
|
+
'bottomRight'
|
|
19
|
+
)
|
|
20
|
+
})
|
|
21
|
+
Then('the header row is visible', () => {
|
|
22
|
+
cy.get('thead > tr > th').should('be.visible')
|
|
23
|
+
})
|
|
24
|
+
Then('the first two datatable columns are visible', () => {
|
|
25
|
+
cy.get('tbody > tr > th:nth-child(1)').should('be.visible')
|
|
26
|
+
cy.get('tbody > tr > th:nth-child(2)').should('be.visible')
|
|
27
|
+
})
|
|
28
|
+
Then('the bottom right scrolling datatable cell is visible', () => {
|
|
29
|
+
cy.get('td').contains('scrolling bottom-right').should('be.visible')
|
|
30
|
+
})
|
|
31
|
+
Then('the top left scrolling datatable cell is not visible', () => {
|
|
32
|
+
cy.get('td').contains('scrolling top-left').should('not.be.visible')
|
|
33
|
+
})
|
|
34
|
+
Then('the bottom left scrolling datatable cell is not visible', () => {
|
|
35
|
+
cy.get('td').contains('scrolling bottom-left').should('not.be.visible')
|
|
36
|
+
})
|
|
37
|
+
Then('the top right scrolling datatable cell is not visible', () => {
|
|
38
|
+
cy.get('td').contains('scrolling top-right').should('not.be.visible')
|
|
39
|
+
})
|
|
40
|
+
Then('the top right scrolling datatable cell is visible', () => {
|
|
41
|
+
cy.get('td').contains('scrolling top-right').should('be.visible')
|
|
42
|
+
})
|
|
43
|
+
Then('the bottom left scrolling datatable cell is visible', () => {
|
|
44
|
+
cy.get('td').contains('scrolling bottom-left').should('be.visible')
|
|
45
|
+
})
|
|
46
|
+
Then('the bottom right scrolling datatable cell is not visible', () => {
|
|
47
|
+
cy.get('td').contains('scrolling bottom-right').should('not.be.visible')
|
|
48
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Feature: Scrolling a DataTable
|
|
2
|
+
|
|
3
|
+
Scenario: The user vertically scrolls the DataTable
|
|
4
|
+
Given a scrolling datatable is rendered
|
|
5
|
+
When the user scrolls down
|
|
6
|
+
Then the header row is visible
|
|
7
|
+
And the first two datatable columns are visible
|
|
8
|
+
And the bottom left scrolling datatable cell is visible
|
|
9
|
+
But the bottom right scrolling datatable cell is not visible
|
|
10
|
+
And the top left scrolling datatable cell is not visible
|
|
11
|
+
And the top right scrolling datatable cell is not visible
|
|
12
|
+
|
|
13
|
+
Scenario: The user horizontally scrolls the DataTable
|
|
14
|
+
Given a scrolling datatable is rendered
|
|
15
|
+
When the user scrolls right
|
|
16
|
+
Then the header row is visible
|
|
17
|
+
And the first two datatable columns are visible
|
|
18
|
+
And the top right scrolling datatable cell is visible
|
|
19
|
+
But the bottom right scrolling datatable cell is not visible
|
|
20
|
+
And the top left scrolling datatable cell is not visible
|
|
21
|
+
And the bottom left scrolling datatable cell is not visible
|
|
22
|
+
|
|
23
|
+
Scenario: The user vertically and horizontally scrolls the DataTable
|
|
24
|
+
Given a scrolling datatable is rendered
|
|
25
|
+
When the user scrolls down and right
|
|
26
|
+
Then the header row is visible
|
|
27
|
+
And the first two datatable columns are visible
|
|
28
|
+
And the bottom right scrolling datatable cell is visible
|
|
29
|
+
But the top left scrolling datatable cell is not visible
|
|
30
|
+
And the bottom left scrolling datatable cell is not visible
|
|
31
|
+
And the top right scrolling datatable cell is not visible
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DataTable } from './data-table.js'
|
|
2
|
+
export { DataTableBody } from './data-table-body.js'
|
|
3
|
+
export { DataTableCell } from './data-table-cell.js'
|
|
4
|
+
export { DataTableColumnHeader } from './data-table-column-header/data-table-column-header.js'
|
|
5
|
+
export { DataTableFoot } from './data-table-foot.js'
|
|
6
|
+
export { DataTableHead } from './data-table-head.js'
|
|
7
|
+
export { DataTableRow } from './data-table-row/data-table-row.js'
|
|
8
|
+
export { DataTableToolbar } from './data-table-toolbar.js'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableBody } from '../table-body.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableBody>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableBody>{children}</TableBody>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(
|
|
15
|
+
<table>
|
|
16
|
+
<TableBody ref={ref} />
|
|
17
|
+
</table>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
expect(wrapper.find('tbody').getDOMNode()).toBe(ref.current)
|
|
21
|
+
})
|
|
22
|
+
it('accepts a className prop', () => {
|
|
23
|
+
const className = 'test'
|
|
24
|
+
const wrapper = shallow(<TableBody className={className} />)
|
|
25
|
+
|
|
26
|
+
expect(wrapper.find('tbody').hasClass(className)).toBe(true)
|
|
27
|
+
})
|
|
28
|
+
it('accepts a dataTest prop', () => {
|
|
29
|
+
const dataTest = 'test'
|
|
30
|
+
const wrapper = shallow(<TableBody dataTest={dataTest} />)
|
|
31
|
+
|
|
32
|
+
expect(wrapper.find('tbody').prop('data-test')).toBe(dataTest)
|
|
33
|
+
})
|
|
34
|
+
it('accepts a role prop', () => {
|
|
35
|
+
const role = 'test'
|
|
36
|
+
const wrapper = shallow(<TableBody role={role} />)
|
|
37
|
+
|
|
38
|
+
expect(wrapper.find('tbody').prop('role')).toBe(role)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableDataCell } from '../table-data-cell/table-data-cell.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableDataCell>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableDataCell>{children}</TableDataCell>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(
|
|
15
|
+
<table>
|
|
16
|
+
<tbody>
|
|
17
|
+
<tr>
|
|
18
|
+
<TableDataCell ref={ref} />
|
|
19
|
+
</tr>
|
|
20
|
+
</tbody>
|
|
21
|
+
</table>
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
expect(wrapper.find('td').getDOMNode()).toBe(ref.current)
|
|
25
|
+
})
|
|
26
|
+
it('accepts an active prop', () => {
|
|
27
|
+
const wrapper = shallow(<TableDataCell active />)
|
|
28
|
+
|
|
29
|
+
expect(wrapper.find('td').hasClass('active')).toBe(true)
|
|
30
|
+
})
|
|
31
|
+
it('accepts an align prop', () => {
|
|
32
|
+
const align = 'right'
|
|
33
|
+
const wrapper = shallow(<TableDataCell align={align} />)
|
|
34
|
+
|
|
35
|
+
expect(wrapper.html()).toContain(`text-align: ${align};`)
|
|
36
|
+
})
|
|
37
|
+
it('accepts a bordered prop', () => {
|
|
38
|
+
const wrapper = shallow(<TableDataCell bordered />)
|
|
39
|
+
|
|
40
|
+
expect(wrapper.find('td').hasClass('bordered')).toBe(true)
|
|
41
|
+
})
|
|
42
|
+
it('accepts a className prop', () => {
|
|
43
|
+
const className = 'test'
|
|
44
|
+
const wrapper = shallow(<TableDataCell className={className} />)
|
|
45
|
+
|
|
46
|
+
expect(wrapper.find('td').hasClass(className)).toBe(true)
|
|
47
|
+
})
|
|
48
|
+
it('accepts a colSpan prop', () => {
|
|
49
|
+
const colSpan = '3'
|
|
50
|
+
const wrapper = shallow(<TableDataCell colSpan={colSpan} />)
|
|
51
|
+
|
|
52
|
+
expect(wrapper.find('td').prop('colSpan')).toBe(colSpan)
|
|
53
|
+
})
|
|
54
|
+
it('accepts a dataTest prop', () => {
|
|
55
|
+
const dataTest = 'test'
|
|
56
|
+
const wrapper = shallow(<TableDataCell dataTest={dataTest} />)
|
|
57
|
+
|
|
58
|
+
expect(wrapper.find('td').prop('data-test')).toBe(dataTest)
|
|
59
|
+
})
|
|
60
|
+
it('accepts an error prop', () => {
|
|
61
|
+
const wrapper = shallow(<TableDataCell error />)
|
|
62
|
+
|
|
63
|
+
expect(wrapper.find('td').hasClass('error')).toBe(true)
|
|
64
|
+
})
|
|
65
|
+
it('accepts a large prop', () => {
|
|
66
|
+
const wrapper = shallow(<TableDataCell large />)
|
|
67
|
+
|
|
68
|
+
expect(wrapper.find('td').hasClass('large')).toBe(true)
|
|
69
|
+
})
|
|
70
|
+
it('accepts a left prop', () => {
|
|
71
|
+
const left = '200px'
|
|
72
|
+
const wrapper = shallow(<TableDataCell left={left} />)
|
|
73
|
+
|
|
74
|
+
expect(wrapper.html()).toContain(`inset-inline-start: ${left};`)
|
|
75
|
+
})
|
|
76
|
+
it('accepts a muted prop', () => {
|
|
77
|
+
const wrapper = shallow(<TableDataCell muted />)
|
|
78
|
+
|
|
79
|
+
expect(wrapper.find('td').hasClass('muted')).toBe(true)
|
|
80
|
+
})
|
|
81
|
+
it('accepts a role prop', () => {
|
|
82
|
+
const role = 'test'
|
|
83
|
+
const wrapper = shallow(<TableDataCell role={role} />)
|
|
84
|
+
|
|
85
|
+
expect(wrapper.find('td').prop('role')).toBe(role)
|
|
86
|
+
})
|
|
87
|
+
it('accepts a rowSpan prop', () => {
|
|
88
|
+
const rowSpan = '3'
|
|
89
|
+
const wrapper = shallow(<TableDataCell rowSpan={rowSpan} />)
|
|
90
|
+
|
|
91
|
+
expect(wrapper.find('td').prop('rowSpan')).toBe(rowSpan)
|
|
92
|
+
})
|
|
93
|
+
it('accepts a scope prop', () => {
|
|
94
|
+
const scope = 'row'
|
|
95
|
+
const wrapper = shallow(<TableDataCell scope={scope} />)
|
|
96
|
+
|
|
97
|
+
expect(wrapper.find('td').prop('scope')).toBe(scope)
|
|
98
|
+
})
|
|
99
|
+
it('accepts a staticStyle prop', () => {
|
|
100
|
+
const wrapper = shallow(<TableDataCell staticStyle />)
|
|
101
|
+
|
|
102
|
+
expect(wrapper.find('td').hasClass('staticStyle')).toBe(true)
|
|
103
|
+
})
|
|
104
|
+
it('accepts a valid prop', () => {
|
|
105
|
+
const wrapper = shallow(<TableDataCell valid />)
|
|
106
|
+
|
|
107
|
+
expect(wrapper.find('td').hasClass('valid')).toBe(true)
|
|
108
|
+
})
|
|
109
|
+
it('accepts a width prop', () => {
|
|
110
|
+
const width = '200px'
|
|
111
|
+
const wrapper = shallow(<TableDataCell width={width} />)
|
|
112
|
+
|
|
113
|
+
expect(wrapper.html()).toContain(`width: ${width};`)
|
|
114
|
+
})
|
|
115
|
+
it('accepts an onClick prop', () => {
|
|
116
|
+
const onClick = jest.fn()
|
|
117
|
+
const wrapper = shallow(<TableDataCell onClick={onClick} />)
|
|
118
|
+
|
|
119
|
+
wrapper.simulate('click')
|
|
120
|
+
|
|
121
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
122
|
+
})
|
|
123
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableFoot } from '../table-foot.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableFoot>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableFoot>{children}</TableFoot>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(
|
|
15
|
+
<table>
|
|
16
|
+
<TableFoot ref={ref} />
|
|
17
|
+
</table>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
expect(wrapper.find('tfoot').getDOMNode()).toBe(ref.current)
|
|
21
|
+
})
|
|
22
|
+
it('accepts a className prop', () => {
|
|
23
|
+
const className = 'test'
|
|
24
|
+
const wrapper = shallow(<TableFoot className={className} />)
|
|
25
|
+
|
|
26
|
+
expect(wrapper.find('tfoot').hasClass(className)).toBe(true)
|
|
27
|
+
})
|
|
28
|
+
it('accepts a dataTest prop', () => {
|
|
29
|
+
const dataTest = 'test'
|
|
30
|
+
const wrapper = shallow(<TableFoot dataTest={dataTest} />)
|
|
31
|
+
|
|
32
|
+
expect(wrapper.find('tfoot').prop('data-test')).toBe(dataTest)
|
|
33
|
+
})
|
|
34
|
+
it('accepts a role prop', () => {
|
|
35
|
+
const role = 'test'
|
|
36
|
+
const wrapper = shallow(<TableFoot role={role} />)
|
|
37
|
+
|
|
38
|
+
expect(wrapper.find('tfoot').prop('role')).toBe(role)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableHead } from '../table-head.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableHead>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableHead>{children}</TableHead>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(
|
|
15
|
+
<table>
|
|
16
|
+
<TableHead ref={ref} />
|
|
17
|
+
</table>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
expect(wrapper.find('thead').getDOMNode()).toBe(ref.current)
|
|
21
|
+
})
|
|
22
|
+
it('accepts a className prop', () => {
|
|
23
|
+
const className = 'test'
|
|
24
|
+
const wrapper = shallow(<TableHead className={className} />)
|
|
25
|
+
|
|
26
|
+
expect(wrapper.find('thead').hasClass(className)).toBe(true)
|
|
27
|
+
})
|
|
28
|
+
it('accepts a dataTest prop', () => {
|
|
29
|
+
const dataTest = 'test'
|
|
30
|
+
const wrapper = shallow(<TableHead dataTest={dataTest} />)
|
|
31
|
+
|
|
32
|
+
expect(wrapper.find('thead').prop('data-test')).toBe(dataTest)
|
|
33
|
+
})
|
|
34
|
+
it('accepts a role prop', () => {
|
|
35
|
+
const role = 'test'
|
|
36
|
+
const wrapper = shallow(<TableHead role={role} />)
|
|
37
|
+
|
|
38
|
+
expect(wrapper.find('thead').prop('role')).toBe(role)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableHeaderCellAction } from '../table-header-cell-action.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableHeaderCellAction>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(
|
|
9
|
+
<TableHeaderCellAction>{children}</TableHeaderCellAction>
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
13
|
+
})
|
|
14
|
+
it('accepts a ref', () => {
|
|
15
|
+
const ref = React.createRef()
|
|
16
|
+
const wrapper = mount(<TableHeaderCellAction ref={ref} />)
|
|
17
|
+
|
|
18
|
+
expect(wrapper.find('button').getDOMNode()).toBe(ref.current)
|
|
19
|
+
})
|
|
20
|
+
it('accepts a className prop', () => {
|
|
21
|
+
const className = 'test'
|
|
22
|
+
const wrapper = shallow(<TableHeaderCellAction className={className} />)
|
|
23
|
+
|
|
24
|
+
expect(wrapper.find('button').hasClass(className)).toBe(true)
|
|
25
|
+
})
|
|
26
|
+
it('accepts a dataTest prop', () => {
|
|
27
|
+
const dataTest = 'test'
|
|
28
|
+
const wrapper = shallow(<TableHeaderCellAction dataTest={dataTest} />)
|
|
29
|
+
|
|
30
|
+
expect(wrapper.find('button').prop('data-test')).toBe(dataTest)
|
|
31
|
+
})
|
|
32
|
+
it('accepts a title prop', () => {
|
|
33
|
+
const title = 'test'
|
|
34
|
+
const wrapper = shallow(<TableHeaderCellAction title={title} />)
|
|
35
|
+
|
|
36
|
+
expect(wrapper.find('button').prop('title')).toBe(title)
|
|
37
|
+
})
|
|
38
|
+
it('accepts an onClick prop', () => {
|
|
39
|
+
const onClick = jest.fn()
|
|
40
|
+
const wrapper = shallow(<TableHeaderCellAction onClick={onClick} />)
|
|
41
|
+
|
|
42
|
+
wrapper.simulate('click')
|
|
43
|
+
|
|
44
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableHeaderCell } from '../table-header-cell/table-header-cell.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableHeaderCell>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableHeaderCell>{children}</TableHeaderCell>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(
|
|
15
|
+
<table>
|
|
16
|
+
<thead>
|
|
17
|
+
<tr>
|
|
18
|
+
<TableHeaderCell ref={ref} />
|
|
19
|
+
</tr>
|
|
20
|
+
</thead>
|
|
21
|
+
</table>
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
expect(wrapper.find('th').getDOMNode()).toBe(ref.current)
|
|
25
|
+
})
|
|
26
|
+
it('accepts an active prop', () => {
|
|
27
|
+
const wrapper = shallow(<TableHeaderCell active />)
|
|
28
|
+
|
|
29
|
+
expect(wrapper.find('th').hasClass('active')).toBe(true)
|
|
30
|
+
})
|
|
31
|
+
it('accepts an align prop', () => {
|
|
32
|
+
const align = 'right'
|
|
33
|
+
const wrapper = shallow(<TableHeaderCell align={align} />)
|
|
34
|
+
|
|
35
|
+
expect(wrapper.html()).toContain(`text-align: ${align};`)
|
|
36
|
+
})
|
|
37
|
+
it('accepts a bordered prop', () => {
|
|
38
|
+
const wrapper = shallow(<TableHeaderCell bordered />)
|
|
39
|
+
|
|
40
|
+
expect(wrapper.find('th').hasClass('bordered')).toBe(true)
|
|
41
|
+
})
|
|
42
|
+
it('accepts a className prop', () => {
|
|
43
|
+
const className = 'test'
|
|
44
|
+
const wrapper = shallow(<TableHeaderCell className={className} />)
|
|
45
|
+
|
|
46
|
+
expect(wrapper.find('th').hasClass(className)).toBe(true)
|
|
47
|
+
})
|
|
48
|
+
it('accepts a colSpan prop', () => {
|
|
49
|
+
const colSpan = '3'
|
|
50
|
+
const wrapper = shallow(<TableHeaderCell colSpan={colSpan} />)
|
|
51
|
+
|
|
52
|
+
expect(wrapper.find('th').prop('colSpan')).toBe(colSpan)
|
|
53
|
+
})
|
|
54
|
+
it('accepts a dataTest prop', () => {
|
|
55
|
+
const dataTest = 'test'
|
|
56
|
+
const wrapper = shallow(<TableHeaderCell dataTest={dataTest} />)
|
|
57
|
+
|
|
58
|
+
expect(wrapper.find('th').prop('data-test')).toBe(dataTest)
|
|
59
|
+
})
|
|
60
|
+
it('accepts an error prop', () => {
|
|
61
|
+
const wrapper = shallow(<TableHeaderCell error />)
|
|
62
|
+
|
|
63
|
+
expect(wrapper.find('th').hasClass('error')).toBe(true)
|
|
64
|
+
})
|
|
65
|
+
it('accepts a fixed prop', () => {
|
|
66
|
+
const wrapper = shallow(<TableHeaderCell fixed />)
|
|
67
|
+
|
|
68
|
+
expect(wrapper.type()).toBe('th')
|
|
69
|
+
expect(wrapper.find('th').hasClass('fixed')).toBe(true)
|
|
70
|
+
})
|
|
71
|
+
it('accepts a large prop', () => {
|
|
72
|
+
const wrapper = shallow(<TableHeaderCell large />)
|
|
73
|
+
|
|
74
|
+
expect(wrapper.find('th').hasClass('large')).toBe(true)
|
|
75
|
+
})
|
|
76
|
+
it('accepts a left prop', () => {
|
|
77
|
+
const left = '200px'
|
|
78
|
+
const wrapper = shallow(<TableHeaderCell left={left} />)
|
|
79
|
+
|
|
80
|
+
expect(wrapper.html()).toContain(`inset-inline-start: ${left};`)
|
|
81
|
+
})
|
|
82
|
+
it('accepts an muted prop', () => {
|
|
83
|
+
const wrapper = shallow(<TableHeaderCell muted />)
|
|
84
|
+
|
|
85
|
+
expect(wrapper.find('th').hasClass('muted')).toBe(true)
|
|
86
|
+
})
|
|
87
|
+
it('accepts a role prop', () => {
|
|
88
|
+
const role = 'test'
|
|
89
|
+
const wrapper = shallow(<TableHeaderCell role={role} />)
|
|
90
|
+
|
|
91
|
+
expect(wrapper.find('th').prop('role')).toBe(role)
|
|
92
|
+
})
|
|
93
|
+
it('accepts a rowSpan prop', () => {
|
|
94
|
+
const rowSpan = '3'
|
|
95
|
+
const wrapper = shallow(<TableHeaderCell rowSpan={rowSpan} />)
|
|
96
|
+
|
|
97
|
+
expect(wrapper.find('th').prop('rowSpan')).toBe(rowSpan)
|
|
98
|
+
})
|
|
99
|
+
it('accepts a scope prop', () => {
|
|
100
|
+
const scope = 'row'
|
|
101
|
+
const wrapper = shallow(<TableHeaderCell scope={scope} />)
|
|
102
|
+
|
|
103
|
+
expect(wrapper.find('th').prop('scope')).toBe(scope)
|
|
104
|
+
})
|
|
105
|
+
it('accepts a top prop', () => {
|
|
106
|
+
const top = '200px'
|
|
107
|
+
const wrapper = shallow(<TableHeaderCell top={top} />)
|
|
108
|
+
|
|
109
|
+
expect(wrapper.html()).toContain(`top: ${top};`)
|
|
110
|
+
})
|
|
111
|
+
it('accepts a valid prop', () => {
|
|
112
|
+
const wrapper = shallow(<TableHeaderCell valid />)
|
|
113
|
+
|
|
114
|
+
expect(wrapper.find('th').hasClass('valid')).toBe(true)
|
|
115
|
+
})
|
|
116
|
+
it('accepts a width prop', () => {
|
|
117
|
+
const width = '200px'
|
|
118
|
+
const wrapper = shallow(<TableHeaderCell width={width} />)
|
|
119
|
+
|
|
120
|
+
expect(wrapper.html()).toContain(`width: ${width};`)
|
|
121
|
+
})
|
|
122
|
+
it('accepts an onClick prop', () => {
|
|
123
|
+
const onClick = jest.fn()
|
|
124
|
+
const wrapper = shallow(<TableHeaderCell onClick={onClick} />)
|
|
125
|
+
|
|
126
|
+
wrapper.simulate('click')
|
|
127
|
+
|
|
128
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableRow } from '../table-row.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableRow>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableRow>{children}</TableRow>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(
|
|
15
|
+
<table>
|
|
16
|
+
<thead>
|
|
17
|
+
<TableRow ref={ref} />
|
|
18
|
+
</thead>
|
|
19
|
+
</table>
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
expect(wrapper.find('tr').getDOMNode()).toBe(ref.current)
|
|
23
|
+
})
|
|
24
|
+
it('accepts a className prop', () => {
|
|
25
|
+
const className = 'test'
|
|
26
|
+
const wrapper = shallow(<TableRow className={className} />)
|
|
27
|
+
|
|
28
|
+
expect(wrapper.find('tr').hasClass(className)).toBe(true)
|
|
29
|
+
})
|
|
30
|
+
it('accepts a dataTest prop', () => {
|
|
31
|
+
const dataTest = 'test'
|
|
32
|
+
const wrapper = shallow(<TableRow dataTest={dataTest} />)
|
|
33
|
+
|
|
34
|
+
expect(wrapper.find('tr').prop('data-test')).toBe(dataTest)
|
|
35
|
+
})
|
|
36
|
+
it('accepts a draggable prop', () => {
|
|
37
|
+
const wrapper = shallow(<TableRow draggable />)
|
|
38
|
+
|
|
39
|
+
expect(wrapper.find('tr').hasClass('draggable')).toBe(true)
|
|
40
|
+
})
|
|
41
|
+
it('accepts a role prop', () => {
|
|
42
|
+
const role = 'test'
|
|
43
|
+
const wrapper = shallow(<TableRow role={role} />)
|
|
44
|
+
|
|
45
|
+
expect(wrapper.find('tr').prop('role')).toBe(role)
|
|
46
|
+
})
|
|
47
|
+
it('accepts a selected prop', () => {
|
|
48
|
+
const wrapper = shallow(<TableRow selected />)
|
|
49
|
+
|
|
50
|
+
expect(wrapper.find('tr').hasClass('selected')).toBe(true)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableScrollBox } from '../table-scroll-box.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableScrollBox>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableScrollBox>{children}</TableScrollBox>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(<TableScrollBox ref={ref} />)
|
|
15
|
+
|
|
16
|
+
expect(wrapper.find('div').getDOMNode()).toBe(ref.current)
|
|
17
|
+
})
|
|
18
|
+
it('accepts a className prop', () => {
|
|
19
|
+
const className = 'test'
|
|
20
|
+
const wrapper = shallow(<TableScrollBox className={className} />)
|
|
21
|
+
|
|
22
|
+
expect(wrapper.find('div').hasClass(className)).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
it('accepts a dataTest prop', () => {
|
|
25
|
+
const dataTest = 'test'
|
|
26
|
+
const wrapper = shallow(<TableScrollBox dataTest={dataTest} />)
|
|
27
|
+
|
|
28
|
+
expect(wrapper.find('div').prop('data-test')).toBe(dataTest)
|
|
29
|
+
})
|
|
30
|
+
it('accepts a maxHeight prop', () => {
|
|
31
|
+
const maxHeight = '200px'
|
|
32
|
+
const wrapper = shallow(<TableScrollBox maxHeight={maxHeight} />)
|
|
33
|
+
expect(wrapper.html()).toContain('max-height: 200px;')
|
|
34
|
+
})
|
|
35
|
+
it('accepts a maxWidth prop', () => {
|
|
36
|
+
const maxWidth = '200px'
|
|
37
|
+
const wrapper = shallow(<TableScrollBox maxWidth={maxWidth} />)
|
|
38
|
+
expect(wrapper.html()).toContain('max-width: 200px;')
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { shallow, mount } from 'enzyme'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { TableToolbar } from '../table-toolbar.js'
|
|
4
|
+
|
|
5
|
+
describe('<TableToolbar>', () => {
|
|
6
|
+
it('renders children', () => {
|
|
7
|
+
const children = 'children'
|
|
8
|
+
const wrapper = shallow(<TableToolbar>{children}</TableToolbar>)
|
|
9
|
+
|
|
10
|
+
expect(wrapper.containsMatchingElement(children)).toBe(true)
|
|
11
|
+
})
|
|
12
|
+
it('accepts a ref', () => {
|
|
13
|
+
const ref = React.createRef()
|
|
14
|
+
const wrapper = mount(<TableToolbar ref={ref} />)
|
|
15
|
+
|
|
16
|
+
expect(wrapper.find('div').getDOMNode()).toBe(ref.current)
|
|
17
|
+
})
|
|
18
|
+
it('accepts a className prop', () => {
|
|
19
|
+
const className = 'test'
|
|
20
|
+
const wrapper = shallow(<TableToolbar className={className} />)
|
|
21
|
+
|
|
22
|
+
expect(wrapper.find('div').hasClass(className)).toBe(true)
|
|
23
|
+
})
|
|
24
|
+
it('accepts a dataTest prop', () => {
|
|
25
|
+
const dataTest = 'test'
|
|
26
|
+
const wrapper = shallow(<TableToolbar dataTest={dataTest} />)
|
|
27
|
+
|
|
28
|
+
expect(wrapper.find('div').prop('data-test')).toBe(dataTest)
|
|
29
|
+
})
|
|
30
|
+
it('accepts a position prop', () => {
|
|
31
|
+
const wrapperDefault = shallow(<TableToolbar />)
|
|
32
|
+
const wrapperTop = shallow(<TableToolbar position="top" />)
|
|
33
|
+
const wrapperBottom = shallow(<TableToolbar position="bottom" />)
|
|
34
|
+
|
|
35
|
+
expect(wrapperDefault.find('div').hasClass('top')).toBe(true)
|
|
36
|
+
expect(wrapperDefault.find('div').hasClass('bottom')).toBe(false)
|
|
37
|
+
|
|
38
|
+
expect(wrapperTop.find('div').hasClass('top')).toBe(true)
|
|
39
|
+
expect(wrapperTop.find('div').hasClass('bottom')).toBe(false)
|
|
40
|
+
|
|
41
|
+
expect(wrapperBottom.find('div').hasClass('top')).toBe(false)
|
|
42
|
+
expect(wrapperBottom.find('div').hasClass('bottom')).toBe(true)
|
|
43
|
+
})
|
|
44
|
+
})
|