grafana/public/app/plugins/datasource/tempo/syntax.test.ts
Connor Lindsey 76b891b001
Tempo: Add Tempo search behind feature flag (#37765)
* Add Tempo search behind feature flag

* Add query fields for Tempo search

* Only show loki search if a logs-to-traces datasource is set up

* Refactor tempo search to use separate fields for service name, span name, and tags

* Add tests to buildSearchQuery

* Move search to separate component and rename type to native search

* Improve Tempo tokenizer syntax
2021-08-19 09:15:46 -06:00

20 lines
1.1 KiB
TypeScript

import { tokenizer } from './syntax';
import Prism from 'prismjs';
describe('Loki syntax', () => {
it('should highlight Loki query correctly', () => {
expect(Prism.highlight('key=value', tokenizer, 'tempo')).toBe(
'<span class="token key attr-name">key</span><span class="token operator">=</span><span class="token value">value</span>'
);
expect(Prism.highlight('root.ip=172.123.0.1', tokenizer, 'tempo')).toBe(
'<span class="token key attr-name">root.ip</span><span class="token operator">=</span><span class="token value">172.123.0.1</span>'
);
expect(Prism.highlight('root.name="http get /config"', tokenizer, 'tempo')).toBe(
'<span class="token key attr-name">root.name</span><span class="token operator">=</span><span class="token value">"http get /config"</span>'
);
expect(Prism.highlight('key=value key2=value2', tokenizer, 'tempo')).toBe(
'<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>'
);
});
});