promql.test.ts 1.6 KB

1234567891011121314151617181920212223
  1. import Prism from 'prismjs';
  2. import promql from './promql';
  3. describe('Loki syntax', () => {
  4. it('should highlight Loki query correctly', () => {
  5. expect(Prism.highlight('{key="val#ue"}', promql, 'promql')).toBe(
  6. '<span class="token context-labels"><span class="token punctuation">{</span><span class="token label-key attr-name">key</span>=<span class="token label-value attr-value">"val#ue"</span></span><span class="token punctuation">}</span>'
  7. );
  8. expect(Prism.highlight('{key="#value"}', promql, 'promql')).toBe(
  9. '<span class="token context-labels"><span class="token punctuation">{</span><span class="token label-key attr-name">key</span>=<span class="token label-value attr-value">"#value"</span></span><span class="token punctuation">}</span>'
  10. );
  11. expect(Prism.highlight('{key="value#"}', promql, 'promql')).toBe(
  12. '<span class="token context-labels"><span class="token punctuation">{</span><span class="token label-key attr-name">key</span>=<span class="token label-value attr-value">"value#"</span></span><span class="token punctuation">}</span>'
  13. );
  14. expect(Prism.highlight('#test{key="value"}', promql, 'promql')).toBe(
  15. '<span class="token comment">#test{key="value"}</span>'
  16. );
  17. expect(Prism.highlight('{key="value"}#test', promql, 'promql')).toBe(
  18. '<span class="token context-labels"><span class="token punctuation">{</span><span class="token label-key attr-name">key</span>=<span class="token label-value attr-value">"value"</span></span><span class="token punctuation">}</span><span class="token comment">#test</span>'
  19. );
  20. });
  21. });