forked from bvaughn/react-virtualized
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColumn.jest.js
More file actions
62 lines (57 loc) · 1.49 KB
/
Column.jest.js
File metadata and controls
62 lines (57 loc) · 1.49 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
import Immutable from 'immutable'
import defaultCellDataGetter from './defaultCellDataGetter'
import defaultCellRenderer from './defaultCellRenderer'
describe('Column', () => {
const rowData = Immutable.Map({
foo: 'Foo',
bar: 1
})
describe('defaultCellDataGetter', () => {
it('should return a value for specified attributes', () => {
expect(defaultCellDataGetter({
dataKey: 'foo',
rowData
})).toEqual('Foo')
expect(defaultCellDataGetter({
dataKey: 'bar',
rowData
})).toEqual(1)
})
it('should return undefined for missing attributes', () => {
expect(defaultCellDataGetter({
dataKey: 'baz',
rowData
})).toEqual(undefined)
})
})
describe('defaultCellRenderer', () => {
it('should render a value for specified attributes', () => {
expect(defaultCellRenderer({
cellData: 'Foo',
dataKey: 'foo',
rowData,
rowIndex: 0
})).toEqual('Foo')
expect(defaultCellRenderer({
cellData: 1,
dataKey: 'bar',
rowData,
rowIndex: 0
})).toEqual('1')
})
it('should render empty string for null or missing attributes', () => {
expect(defaultCellRenderer({
cellData: null,
dataKey: 'baz',
rowData,
rowIndex: 0
})).toEqual('')
expect(defaultCellRenderer({
cellData: undefined,
dataKey: 'baz',
rowData,
rowIndex: 0
})).toEqual('')
})
})
})