mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Chore: Fix typescript strict null errors * Added new limit * Fixed ts issue * fixed tests * trying to fix type inference * Fixing more ts errors * Revert tsconfig option * Fix * Fixed code * More fixes * fix tests * Updated snapshot
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { getHighlighterExpressionsFromQuery } from './query_utils';
|
|
|
|
describe('getHighlighterExpressionsFromQuery', () => {
|
|
it('returns no expressions for empty query', () => {
|
|
expect(getHighlighterExpressionsFromQuery('')).toEqual([]);
|
|
});
|
|
|
|
it('returns an expression for query with filter', () => {
|
|
expect(getHighlighterExpressionsFromQuery('{foo="bar"} |= "x"')).toEqual(['x']);
|
|
});
|
|
|
|
it('returns expressions for query with filter chain', () => {
|
|
expect(getHighlighterExpressionsFromQuery('{foo="bar"} |= "x" |~ "y"')).toEqual(['x', 'y']);
|
|
});
|
|
|
|
it('returns drops expressions for query with negative filter chain', () => {
|
|
expect(getHighlighterExpressionsFromQuery('{foo="bar"} |= "x" != "y"')).toEqual(['x']);
|
|
});
|
|
|
|
it('returns null if filter term is not wrapped in double quotes', () => {
|
|
expect(getHighlighterExpressionsFromQuery('{foo="bar"} |= x')).toEqual([]);
|
|
});
|
|
|
|
it('escapes filter term if regex filter operator is not used', () => {
|
|
expect(getHighlighterExpressionsFromQuery('{foo="bar"} |= "x[yz].w"')).toEqual(['x\\[yz\\]\\.w']);
|
|
});
|
|
|
|
it('does not escape filter term if regex filter operator is used', () => {
|
|
expect(getHighlighterExpressionsFromQuery('{foo="bar"} |~ "x[yz].w" |~ "z.+"')).toEqual(['x[yz].w', 'z.+']);
|
|
});
|
|
});
|