renderer.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import {
  3. FilterType,
  4. ParseResult,
  5. TermOperator,
  6. Token,
  7. TokenResult,
  8. } from 'sentry/components/searchSyntax/parser';
  9. import HighlightQuery from './renderer';
  10. const query: ParseResult = [
  11. {
  12. type: Token.FILTER,
  13. filter: FilterType.TEXT,
  14. negated: false,
  15. key: {
  16. type: Token.KEY_SIMPLE,
  17. value: 'user.email',
  18. quoted: false,
  19. text: 'user.email',
  20. location: {
  21. start: {offset: 0, line: 1, column: 1},
  22. end: {offset: 10, line: 1, column: 11},
  23. },
  24. },
  25. operator: TermOperator.DEFAULT,
  26. value: {
  27. type: Token.VALUE_TEXT,
  28. value: 'foo@example.com',
  29. quoted: false,
  30. text: 'foo@example.com',
  31. location: {
  32. start: {offset: 11, line: 1, column: 12},
  33. end: {offset: 27, line: 1, column: 28},
  34. },
  35. },
  36. invalid: null,
  37. warning: null,
  38. text: 'user.email:foo@example.com',
  39. location: {
  40. start: {offset: 0, line: 1, column: 1},
  41. end: {offset: 27, line: 1, column: 28},
  42. },
  43. } satisfies TokenResult<Token.FILTER>,
  44. ];
  45. describe('SmartSearchBar', function () {
  46. it('renders the query', function () {
  47. render(<HighlightQuery parsedQuery={query} cursorPosition={-1} />);
  48. expect(screen.getByText('user.email:')).toBeInTheDocument();
  49. expect(screen.getByText('foo@example.com')).toBeInTheDocument();
  50. });
  51. });