admin-on-rest-fr05t1k
Version:
A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI
60 lines (51 loc) • 1.75 kB
JavaScript
import assert from 'assert';
import React from 'react';
import { shallow } from 'enzyme';
import { DatagridHeaderCell } from './DatagridHeaderCell';
describe('<DatagridHeaderCell />', () => {
describe('sorting on a column', () => {
const defaultField = {
type: 'foo',
props: {},
updateSort: () => {},
};
it('should be enabled when field has a source', () => {
const wrapper = shallow((
<DatagridHeaderCell
currentSort={{}}
field={{
...defaultField,
props: {
source: 'title',
},
}}
/>
));
assert.equal(wrapper.find('FlatButton').length, 1);
});
it('should be disabled when field has no source', () => {
const wrapper = shallow((
<DatagridHeaderCell
currentSort={{}}
field={{ ...defaultField }}
/>
));
assert.equal(wrapper.find('FlatButton').length, 0);
});
it('should be disabled when sortable prop is explicitly set to false', () => {
const wrapper = shallow((
<DatagridHeaderCell
currentSort={{}}
field={{
...defaultField,
props: {
source: 'title',
sortable: false,
},
}}
/>
));
assert.equal(wrapper.find('FlatButton').length, 0);
});
});
});