Skip to content

Commit c676303

Browse files
committed
fix: tests
1 parent 2e3f9f1 commit c676303

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/lib/columns.newDataColumn.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ it('falls back on the string accessor as id', () => {
2828
expect(actual.id).toBe('firstName');
2929
});
3030

31-
it('throws if id is undefined without string accessor', () => {
31+
it('throws if id is undefined without string accessor or header', () => {
3232
expect(() => {
3333
new DataColumn<User>({
34-
header: 'First Name',
35-
accessor: (u) => u.firstName,
36-
});
37-
}).toThrowError('A column id or string accessor is required');
34+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
35+
accessor: (u: any) => u.firstName,
36+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
37+
} as any);
38+
}).toThrowError('A column id, string accessor, or header is required');
3839
});

src/lib/columns.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ export class DataColumn<
136136
if (id === undefined && this.accessorKey === undefined && header === undefined) {
137137
throw new Error('A column id, string accessor, or header is required');
138138
}
139-
this.id = (id ?? this.accessorKey ? String(this.accessorKey) : String(header)) as Id;
139+
const accessorKeyId = typeof this.accessorKey === 'string' ? this.accessorKey : null;
140+
this.id = (id ?? accessorKeyId ?? String(header)) as Id;
140141
}
141142

142143
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)