Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/data-table/__tests__/highlight-cell-text.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright (c) Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { render } from '@testing-library/react';

import { HighlightCellText } from '../text-search';

describe('HighlightCellText', () => {
it('renders the text value when there is no active query', () => {
const { container } = render(<HighlightCellText text="hello world" query="" />);
expect(container.textContent).toBe('hello world');
});

it('renders the text value with the matching segment highlighted', () => {
const { container } = render(<HighlightCellText text="hello world" query="world" />);
expect(container.textContent).toBe('hello world');
});
});
2 changes: 1 addition & 1 deletion src/data-table/text-search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const HighlightCellText: React.FC<{ text: string; query: string }> = (pro
const [css, theme] = useStyletron();

if (!props.query) {
return <>props.text</>;
return <>{props.text}</>;
}

return (
Expand Down