fixed-react-data-grid-custom
Version:
Excel-like grid component built with React, with editors, keyboard navigation, copy & paste, and the like
39 lines (30 loc) • 1.01 kB
JavaScript
import React from 'react';
import { mount } from 'enzyme';
import CellExpander from '../CellExpander';
import { CellExpand } from 'common/constants';
const setup = (overrideExpandableOptions = {}) => {
const props = {
expandableOptions: {
expanded: true,
...overrideExpandableOptions
},
onCellExpand: jasmine.createSpy()
};
return {
props,
wrapper: mount(<CellExpander {...props} />)
};
};
describe('CellExpand', () => {
it('should create an instance of CellExpand', () => {
const { wrapper } = setup({ expanded: false });
expect(wrapper.find('.rdg-cell-expand').length).toBe(1);
expect(wrapper.find('span').text()).toBe(CellExpand.RIGHT_TRIANGLE);
});
it('should call onCellExpand when clicked', () => {
const { wrapper, props } = setup({ expanded: false });
wrapper.find('span').simulate('click');
expect(props.onCellExpand.calls.count()).toEqual(1);
expect(wrapper.find('span').text()).toBe(CellExpand.DOWN_TRIANGLE);
});
});