2019-10-31 04:48:05 -05:00
|
|
|
import { DataQuery } from '@grafana/data';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2019-03-18 05:21:40 -05:00
|
|
|
import { getNextRefIdChar } from './query';
|
|
|
|
|
2021-06-23 08:23:02 -05:00
|
|
|
function dataQueryHelper(ids: string[]): DataQuery[] {
|
|
|
|
return ids.map((letter) => {
|
|
|
|
return { refId: letter };
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const singleDataQuery: DataQuery[] = dataQueryHelper('ABCDE'.split(''));
|
|
|
|
const outOfOrderDataQuery: DataQuery[] = dataQueryHelper('ABD'.split(''));
|
|
|
|
const singleExtendedDataQuery: DataQuery[] = dataQueryHelper('ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''));
|
2019-03-18 05:21:40 -05:00
|
|
|
|
|
|
|
describe('Get next refId char', () => {
|
|
|
|
it('should return next char', () => {
|
2021-06-23 08:23:02 -05:00
|
|
|
expect(getNextRefIdChar(singleDataQuery)).toEqual('F');
|
2019-03-18 05:21:40 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should get first char', () => {
|
|
|
|
expect(getNextRefIdChar([])).toEqual('A');
|
|
|
|
});
|
2021-06-23 08:23:02 -05:00
|
|
|
|
|
|
|
it('should get the first avaliable character if a query has been deleted out of order', () => {
|
|
|
|
expect(getNextRefIdChar(outOfOrderDataQuery)).toEqual('C');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should append a new char and start from AA when Z is reached', () => {
|
|
|
|
expect(getNextRefIdChar(singleExtendedDataQuery)).toEqual('AA');
|
|
|
|
});
|
2019-03-18 05:21:40 -05:00
|
|
|
});
|