-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathstickySelectionColumn.test.ts
More file actions
112 lines (100 loc) · 3.2 KB
/
Copy pathstickySelectionColumn.test.ts
File metadata and controls
112 lines (100 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import {
mergeFirstStickyDataColumnProps,
shouldIncludeStickySelectionColumn,
STICKY_SELECTION_COLUMN_WIDTH,
stickySelectionCellProps,
} from './stickySelectionColumn';
describe('stickySelectionColumn', () => {
describe('stickySelectionCellProps', () => {
it('matches row-selection sticky grouping props', () => {
expect(stickySelectionCellProps).toEqual({
isStickyColumn: true,
hasRightBorder: false,
stickyMinWidth: STICKY_SELECTION_COLUMN_WIDTH,
});
});
});
describe('shouldIncludeStickySelectionColumn', () => {
it('is true when table is sticky, selectable, and first column is sticky', () => {
expect(
shouldIncludeStickySelectionColumn(
[ { cell: 'Name', props: { isStickyColumn: true } } ],
true,
true
)
).toBe(true);
});
it('is false when table is not sticky', () => {
expect(
shouldIncludeStickySelectionColumn(
[ { cell: 'Name', props: { isStickyColumn: true } } ],
true,
false
)
).toBe(false);
});
it('is false when not selectable', () => {
expect(
shouldIncludeStickySelectionColumn(
[ { cell: 'Name', props: { isStickyColumn: true } } ],
false,
true
)
).toBe(false);
});
it('is false when first column is not sticky', () => {
expect(
shouldIncludeStickySelectionColumn(
[ { cell: 'Name', props: { isStickyColumn: false } } ],
true,
true
)
).toBe(false);
});
it('is false when columns is empty', () => {
expect(shouldIncludeStickySelectionColumn([], true, true)).toBe(false);
});
it('is false when first column entry is null', () => {
expect(
shouldIncludeStickySelectionColumn([ null, { cell: 'Name', props: { isStickyColumn: true } } ], true, true)
).toBe(false);
});
});
describe('mergeFirstStickyDataColumnProps', () => {
it('adds stickyLeftOffset when including selection sticky', () => {
expect(
mergeFirstStickyDataColumnProps(
{ isStickyColumn: true, hasRightBorder: true },
true
)
).toEqual({
isStickyColumn: true,
hasRightBorder: true,
stickyLeftOffset: STICKY_SELECTION_COLUMN_WIDTH,
});
});
it('preserves existing stickyLeftOffset', () => {
expect(
mergeFirstStickyDataColumnProps(
{ isStickyColumn: true, stickyLeftOffset: '80px' },
true
)
).toEqual({
isStickyColumn: true,
stickyLeftOffset: '80px',
});
});
it('does not merge when first column is not sticky', () => {
expect(
mergeFirstStickyDataColumnProps({ isStickyColumn: false }, true)
).toEqual({ isStickyColumn: false });
});
it('returns column props unchanged when not including sticky selection', () => {
const props = { isStickyColumn: true, hasRightBorder: true };
expect(mergeFirstStickyDataColumnProps(props, false)).toBe(props);
});
it('returns undefined when column props are undefined', () => {
expect(mergeFirstStickyDataColumnProps(undefined, true)).toBeUndefined();
});
});
});