syntax.test.ts 1.1 KB

1234567891011121314151617181920
  1. import Prism from 'prismjs';
  2. import { tokenizer } from './syntax';
  3. describe('Loki syntax', () => {
  4. it('should highlight Loki query correctly', () => {
  5. expect(Prism.highlight('key=value', tokenizer, 'tempo')).toBe(
  6. '<span class="token key attr-name">key</span><span class="token operator">=</span><span class="token value">value</span>'
  7. );
  8. expect(Prism.highlight('root.ip=172.123.0.1', tokenizer, 'tempo')).toBe(
  9. '<span class="token key attr-name">root.ip</span><span class="token operator">=</span><span class="token value">172.123.0.1</span>'
  10. );
  11. expect(Prism.highlight('root.name="http get /config"', tokenizer, 'tempo')).toBe(
  12. '<span class="token key attr-name">root.name</span><span class="token operator">=</span><span class="token value">"http get /config"</span>'
  13. );
  14. expect(Prism.highlight('key=value key2=value2', tokenizer, 'tempo')).toBe(
  15. '<span class="token key attr-name">key</span><span class="token operator">=</span><span class="token value">value</span> <span class="token key attr-name">key2</span><span class="token operator">=</span><span class="token value">value2</span>'
  16. );
  17. });
  18. });