-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flat-table-cell, flat-table-row-header): add width prop to table…
… cell and new truncate styling Adds `width` prop for `FlatTableCell`. Adds `truncate` and `title` props to support styling content that overflows the width of the column and overriding the text displayed when the mouse hovers over a cell.
- Loading branch information
Showing
12 changed files
with
302 additions
and
40 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
60 changes: 60 additions & 0 deletions
60
src/components/flat-table/flat-table-cell/flat-table-cell.spec.js
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,60 @@ | ||
import React from "react"; | ||
import { mount } from "enzyme"; | ||
|
||
import { StyledFlatTableCell } from "./flat-table-cell.style"; | ||
import FlatTableRowCell from "./flat-table-cell.component"; | ||
import { assertStyleMatch } from "../../../__spec_helper__/test-utils"; | ||
|
||
describe("FlatTableRowCell", () => { | ||
it("renders with proper width style rule when width prop is passed", () => { | ||
const wrapper = mount(<FlatTableRowCell width={40} />); | ||
assertStyleMatch( | ||
{ | ||
width: "40px", | ||
}, | ||
wrapper.find(StyledFlatTableCell) | ||
); | ||
|
||
assertStyleMatch( | ||
{ | ||
width: "40px", | ||
}, | ||
wrapper.find(StyledFlatTableCell), | ||
{ modifier: "&&& > div" } | ||
); | ||
}); | ||
|
||
describe("when truncate prop is true", () => { | ||
let wrapper; | ||
beforeEach(() => { | ||
wrapper = mount(<FlatTableRowCell truncate>Foo</FlatTableRowCell>); | ||
}); | ||
|
||
it("should apply expected styling", () => { | ||
assertStyleMatch( | ||
{ | ||
textOverflow: "ellipsis", | ||
overflow: "hidden", | ||
whiteSpace: "nowrap", | ||
}, | ||
wrapper.find(StyledFlatTableCell), | ||
{ modifier: "&&& > div" } | ||
); | ||
}); | ||
|
||
it("should set the title if children is string", () => { | ||
expect(wrapper.find("div").props().title).toEqual("Foo"); | ||
}); | ||
|
||
describe("and title prop is set", () => { | ||
it("should override the default behaviour", () => { | ||
wrapper = mount( | ||
<FlatTableRowCell truncate title="Bar"> | ||
Foo | ||
</FlatTableRowCell> | ||
); | ||
expect(wrapper.find("div").props().title).toEqual("Bar"); | ||
}); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.