This repository has been archived by the owner on Sep 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import { spy, stub } from 'sinon'; | ||
import { mount, shallow } from 'enzyme'; | ||
import { assert, expect, should } from 'chai'; | ||
import textLabels from '../src/textLabels'; | ||
import TableBodyCell from '../src/components/TableBodyCell'; | ||
|
||
describe('<TableBodyCell />', function() { | ||
let classes; | ||
|
||
before(() => { | ||
classes = { | ||
root: {}, | ||
}; | ||
}); | ||
|
||
it('should trigger onCellClick prop callback when clicking cell', () => { | ||
const options = { sort: true, textLabels, onCellClick: spy() }; | ||
|
||
const fullWrapper = mount( | ||
<TableBodyCell | ||
options={options} | ||
colIndex={0} | ||
rowIndex={0} | ||
dataIndex={0} | ||
print={false} | ||
columnHeader="Header" | ||
onCellClick={options.onCellClick} | ||
classes={classes}> | ||
some content | ||
</TableBodyCell>, | ||
); | ||
|
||
// The test should click on both TDs that are rendered, but only 1 onCellClick | ||
// should fire because the first TD represents the column header (due to responsive design). | ||
fullWrapper.find('td').forEach(item => { | ||
item.simulate('click'); | ||
}); | ||
|
||
assert.strictEqual(options.onCellClick.callCount, 1); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters