Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
Signed-off-by: ananzh <ananzh@amazon.com>
  • Loading branch information
ananzh committed Oct 10, 2023
1 parent 4e05551 commit 05ee6cb
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ describe('filterColumns', () => {
getAll: () => [{ name: 'a' }, { name: 'c' }, { name: 'd' }],
},
} as IndexPattern;
const defaultColumns = ['_defaultColumn'];

it('should return columns that exist in the index pattern fields', () => {
const columns = ['a', 'b'];
const result = filterColumns(columns, indexPatternMock, defaultColumns);
const result = filterColumns(columns, indexPatternMock, ['a']);
expect(result).toEqual(['a']);
});

it('should return defaultColumns if no columns exist in the index pattern fields', () => {
const columns = ['b', 'e'];
const result = filterColumns(columns, indexPatternMock, defaultColumns);
expect(result).toEqual(defaultColumns);
const result = filterColumns(columns, indexPatternMock, ['e']);
expect(result).toEqual(['_source']);
});

it('should return defaultColumns if no columns and indexPattern is null', () => {
it('should return defaultColumns if no columns and indexPattern is undefined', () => {
const columns = ['b', 'e'];
const result = filterColumns(columns, null, defaultColumns);
expect(result).toEqual(defaultColumns);
const result = filterColumns(columns, undefined, ['a']);
expect(result).toEqual(['_source']);
});
});

0 comments on commit 05ee6cb

Please sign in to comment.