-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DataGrid] Throw if rows id is missing (#349)
* remove the need for a row id * fix prettier * Rename createRow to createRowModel * throw error when row has no id * fix error message and added test
- Loading branch information
Showing
4 changed files
with
40 additions
and
4 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
15 changes: 15 additions & 0 deletions
15
packages/grid/_modules_/grid/models/__tests__/rows.tests.ts
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,15 @@ | ||
import { createRowModel, RowData } from '../rows'; | ||
|
||
describe('Row: createRowModel', () => { | ||
it('should have an id', () => { | ||
const row = { | ||
name: 'damien', | ||
}; | ||
const expectedError = [ | ||
'Material-UI: The data grid component requires all rows to have a unique id property.', | ||
'A row was provided without in the rows prop:', | ||
JSON.stringify(row), | ||
].join('\n'); | ||
expect(() => createRowModel(<RowData>(<unknown>row))).toThrow(expectedError); | ||
}); | ||
}); |
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