-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add select option to simple table (#197)
* Add select option to simple table * Add tablerow type changes * Add Table changes * Update table styling * change cells to items * Rename cells to items * Fix incorrect assignment * Optimize table code * Update border token * Update items to have index passed onSelect * Update naming of onSelect props * Optimise Table code * Fix incorrect assignment
- v0.0.152
- v0.0.149
- v0.0.148
- v0.0.139
- v0.0.63
- v0.0.62
- v.0.0.56
- v0.0.55
- v0.0.53
- v0.0.52
- v0.0.51
- v0.0.50
- v0.0.49
- v0.0.48
- v0.0.47
- v0.0.46
- 0.0.188
- 0.0.187
- 0.0.186
- 0.0.185
- 0.0.184
- 0.0.183
- 0.0.182
- 0.0.181
- 0.0.180
- 0.0.179
- 0.0.178
- 0.0.177
- 0.0.176
- 0.0.175
- 0.0.174
- 0.0.173
- 0.0.172
- 0.0.171
- 0.0.170
- 0.0.169
- 0.0.168
- 0.0.167
- 0.0.166
- 0.0.165
- 0.0.164
- 0.0.163
- 0.0.162
- 0.0.161
- 0.0.160
- 0.0.159
- 0.0.158
- 0.0.157
- 0.0.156
- 0.0.155
- 0.0.154
- 0.0.153
- 0.0.151
- 0.0.150
- 0.0.147
- 0.0.146
- 0.0.145
- 0.0.144
- 0.0.143
- 0.0.142
- 0.0.141
- 0.0.140
- 0.0.138
- 0.0.137
- 0.0.136
- 0.0.135
- 0.0.134
- 0.0.133
- 0.0.132
- 0.0.131
- 0.0.130
- 0.0.129
- 0.0.128
- 0.0.127
- 0.0.126
- 0.0.125
- 0.0.124
- 0.0.123
- 0.0.122
- 0.0.121
- 0.0.120
- 0.0.119
- 0.0.118
- 0.0.117
- 0.0.116
- 0.0.115
- 0.0.114
- 0.0.113
- 0.0.112
- 0.0.111
- 0.0.110
- 0.0.109
- 0.0.108
- 0.0.107
- 0.0.106
- 0.0.105
- 0.0.104
- 0.0.103
- 0.0.102
- 0.0.101
- 0.0.100
- 0.0.99
- 0.0.98
- 0.0.97
- 0.0.96
- 0.0.95
- 0.0.94
- 0.0.93
- 0.0.92
- 0.0.91
- 0.0.90
- 0.0.89
- 0.0.88
- 0.0.87
- 0.0.86
- 0.0.85
- 0.0.84
- 0.0.83
- 0.0.82
- 0.0.81
- 0.0.80
- 0.0.79
- 0.0.78
- 0.0.77
- 0.0.76
- 0.0.75
- 0.0.74
- 0.0.73
- 0.0.72
- 0.0.71
- 0.0.70
- 0.0.69
- 0.0.67
- 0.0.66
- 0.0.65
- 0.0.64-10
- 0.0.64-9
- 0.0.64-8
- 0.0.64-7
- 0.0.64-6
- 0.0.64-4
- 0.0.64-3
- 0.0.64-2
- 0.0.64-1
- 0.0.64-0
- 0.0.63
- 0.0.61
- 0.0.60
- 0.0.59
- 0.0.58
- 0.0.57
- 0.0.54
- 0.0.0
1 parent
5c15857
commit 65440e7
Showing
6 changed files
with
344 additions
and
45 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,71 @@ | ||
import { fireEvent } from "@testing-library/react"; | ||
import { Table, TableProps } from "./Table"; | ||
import { renderCUI } from "@/utils/test-utils"; | ||
|
||
const headers = [{ label: "Company" }, { label: "Contact" }, { label: "Country" }]; | ||
|
||
const rows = [ | ||
{ | ||
id: "row-1", | ||
items: [ | ||
{ label: "Alfreds Futterkiste" }, | ||
{ label: "Maria Anders" }, | ||
{ label: "Germany" }, | ||
], | ||
}, | ||
{ | ||
id: "row-2", | ||
items: [ | ||
{ label: "Centro comercial Moctezuma" }, | ||
{ label: "Francisco Chang" }, | ||
{ label: "Mexico" }, | ||
], | ||
}, | ||
]; | ||
|
||
describe("Table", () => { | ||
const renderTable = (props: Omit<TableProps, "headers" | "rows">) => | ||
renderCUI( | ||
<Table | ||
headers={headers} | ||
rows={rows} | ||
data-testid="table" | ||
{...props} | ||
/> | ||
); | ||
|
||
it("should render the Table", () => { | ||
const { queryByTestId } = renderTable({}); | ||
expect(queryByTestId("table")).not.toBeNull(); | ||
expect(queryByTestId("checkbox")).toBeNull(); | ||
}); | ||
|
||
it("should show checkbox on isSelectable", () => { | ||
const { queryByTestId, queryAllByTestId } = renderTable({ | ||
isSelectable: true, | ||
selectedIds: [], | ||
}); | ||
expect(queryByTestId("table")).not.toBeNull(); | ||
expect(queryAllByTestId("checkbox")[0]).not.toBeNull(); | ||
expect(queryAllByTestId("checkbox")[1]).not.toBeNull(); | ||
}); | ||
|
||
it("should trigger onSelect on clicking checkbox", () => { | ||
const onSelect = jest.fn(); | ||
const { queryByTestId, queryAllByTestId } = renderTable({ | ||
isSelectable: true, | ||
selectedIds: [], | ||
onSelect, | ||
}); | ||
expect(queryByTestId("table")).not.toBeNull(); | ||
expect(queryAllByTestId("checkbox")).toHaveLength(4); | ||
const selectAllCheckbox = queryAllByTestId("checkbox")[1]; | ||
const rowCheckbox = queryAllByTestId("checkbox")[2]; | ||
expect(selectAllCheckbox).not.toBeNull(); | ||
fireEvent.click(selectAllCheckbox); | ||
expect(onSelect).toBeCalledTimes(1); | ||
expect(rowCheckbox).not.toBeNull(); | ||
fireEvent.click(selectAllCheckbox); | ||
expect(onSelect).toBeCalledTimes(2); | ||
}); | ||
}); |
Oops, something went wrong.
65440e7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
click-ui – ./
click-ui.vercel.app
click-ui-clickhouse.vercel.app
click-ui-git-main-clickhouse.vercel.app