Skip to content

Commit

Permalink
- update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-goldstein committed May 17, 2022
1 parent dcf7e86 commit 6d40b93
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface BrowserField {
name: string;
searchable: boolean;
type: string;
esTypes?: string[];
subType?: IFieldSubType;
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,26 @@ const ColumnHeaderComponent: React.FC<ColumneHeaderProps> = ({
const onColumnSort = useCallback(
(sortDirection: Direction) => {
const columnId = header.id;
const columnType = header.type ?? '';
const esTypes = header.esTypes ?? [];
const headerIndex = sort.findIndex((col) => col.columnId === columnId);
const newSort =
headerIndex === -1
? [
...sort,
{
columnId,
columnType: `${header.type}`,
columnType,
esTypes,
sortDirection,
},
]
: [
...sort.slice(0, headerIndex),
{
columnId,
columnType: `${header.type}`,
columnType,
esTypes,
sortDirection,
},
...sort.slice(headerIndex + 1),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ describe('Header', () => {
{
columnId: columnHeader.id,
columnType: columnHeader.type ?? 'number',
esTypes: ['date'],
sortDirection: Direction.asc, // (because the previous state was Direction.desc)
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const HeaderComponent: React.FC<Props> = ({ header, sort, timelineId }) =

const onColumnSort = useCallback(() => {
const columnId = header.id;
const columnType = header.type ?? 'text';
const columnType = header.type ?? '';
const esTypes = header.esTypes ?? [];
const sortDirection = getNewSortDirectionOnClick({
clickedHeader: header,
currentSort: sort,
Expand All @@ -40,6 +41,7 @@ export const HeaderComponent: React.FC<Props> = ({ header, sort, timelineId }) =
{
columnId,
columnType,
esTypes,
sortDirection,
},
];
Expand All @@ -49,6 +51,7 @@ export const HeaderComponent: React.FC<Props> = ({ header, sort, timelineId }) =
{
columnId,
columnType,
esTypes,
sortDirection,
},
...sort.slice(headerIndex + 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ describe('ColumnHeaders', () => {
const sort: Sort[] = [
{
columnId: '@timestamp',
columnType: 'number',
columnType: 'date',
esTypes: ['date'],
sortDirection: Direction.desc,
},
];
Expand Down Expand Up @@ -140,12 +141,14 @@ describe('ColumnHeaders', () => {
let mockSort: Sort[] = [
{
columnId: '@timestamp',
columnType: 'number',
columnType: 'date',
esTypes: ['date'],
sortDirection: Direction.desc,
},
{
columnId: 'host.name',
columnType: 'text',
columnType: 'string',
esTypes: [],
sortDirection: Direction.asc,
},
];
Expand All @@ -160,12 +163,14 @@ describe('ColumnHeaders', () => {
mockSort = [
{
columnId: '@timestamp',
columnType: 'number',
columnType: 'date',
esTypes: ['date'],
sortDirection: Direction.desc,
},
{
columnId: 'host.name',
columnType: 'text',
columnType: 'string',
esTypes: [],
sortDirection: Direction.asc,
},
];
Expand Down Expand Up @@ -201,15 +206,22 @@ describe('ColumnHeaders', () => {
sort: [
{
columnId: '@timestamp',
columnType: 'number',
columnType: 'date',
esTypes: ['date'],
sortDirection: Direction.desc,
},
{
columnId: 'host.name',
columnType: 'text',
columnType: 'string',
esTypes: [],
sortDirection: Direction.asc,
},
{ columnId: 'event.category', columnType: 'text', sortDirection: Direction.desc },
{
columnId: 'event.category',
columnType: '',
esTypes: [],
sortDirection: Direction.desc,
},
],
})
);
Expand Down Expand Up @@ -245,10 +257,16 @@ describe('ColumnHeaders', () => {
sort: [
{
columnId: '@timestamp',
columnType: 'number',
columnType: 'date',
esTypes: ['date'],
sortDirection: Direction.asc,
},
{
columnId: 'host.name',
columnType: 'string',
esTypes: [],
sortDirection: Direction.asc,
},
{ columnId: 'host.name', columnType: 'text', sortDirection: Direction.asc },
],
})
);
Expand Down Expand Up @@ -284,10 +302,16 @@ describe('ColumnHeaders', () => {
sort: [
{
columnId: '@timestamp',
columnType: 'number',
columnType: 'date',
esTypes: ['date'],
sortDirection: Direction.desc,
},
{
columnId: 'host.name',
columnType: '',
esTypes: [],
sortDirection: Direction.desc,
},
{ columnId: 'host.name', columnType: 'text', sortDirection: Direction.desc },
],
})
);
Expand Down

0 comments on commit 6d40b93

Please sign in to comment.