forked from bvaughn/react-virtualized
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSection.jest.js
42 lines (37 loc) · 1.08 KB
/
Section.jest.js
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
import Section from './Section';
describe('Section', () => {
function helper({height = 100, width = 200, x = 0, y = 0} = {}) {
return new Section({
height,
width,
x,
y,
});
}
it('should add a new cell index', () => {
const section = helper();
expect(section.getCellIndices()).toEqual([]);
section.addCellIndex({index: 0});
expect(section.getCellIndices()).toEqual([0]);
section.addCellIndex({index: 1});
expect(section.getCellIndices()).toEqual([0, 1]);
});
it('should not add a duplicate cell index', () => {
const section = helper();
section.addCellIndex({index: 0});
section.addCellIndex({index: 1});
section.addCellIndex({index: 0});
section.addCellIndex({index: 1});
section.addCellIndex({index: 2});
expect(section.getCellIndices()).toEqual([0, 1, 2]);
});
it('should define a working toString() method for debugging', () => {
const section = helper({
height: 100,
width: 200,
x: 25,
y: 50,
});
expect(section.toString()).toEqual('25,50 200x100');
});
});