mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
changed functions to arrowfunctions for only-arrow-functions rule (#13127)
This commit is contained in:
committed by
Torkel Ödegaard
parent
826dfceac0
commit
0f326f18dc
@@ -1,7 +1,7 @@
|
||||
import gfunc from '../gfunc';
|
||||
|
||||
describe('when creating func instance from func names', function() {
|
||||
it('should return func instance', function() {
|
||||
describe('when creating func instance from func names', () => {
|
||||
it('should return func instance', () => {
|
||||
const func = gfunc.createFuncInstance('sumSeries');
|
||||
expect(func).toBeTruthy();
|
||||
expect(func.def.name).toEqual('sumSeries');
|
||||
@@ -10,18 +10,18 @@ describe('when creating func instance from func names', function() {
|
||||
expect(func.def.defaultParams.length).toEqual(1);
|
||||
});
|
||||
|
||||
it('should return func instance with shortName', function() {
|
||||
it('should return func instance with shortName', () => {
|
||||
const func = gfunc.createFuncInstance('sum');
|
||||
expect(func).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return func instance from funcDef', function() {
|
||||
it('should return func instance from funcDef', () => {
|
||||
const func = gfunc.createFuncInstance('sum');
|
||||
const func2 = gfunc.createFuncInstance(func.def);
|
||||
expect(func2).toBeTruthy();
|
||||
});
|
||||
|
||||
it('func instance should have text representation', function() {
|
||||
it('func instance should have text representation', () => {
|
||||
const func = gfunc.createFuncInstance('groupByNode');
|
||||
func.params[0] = 5;
|
||||
func.params[1] = 'avg';
|
||||
@@ -30,78 +30,78 @@ describe('when creating func instance from func names', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when rendering func instance', function() {
|
||||
it('should handle single metric param', function() {
|
||||
describe('when rendering func instance', () => {
|
||||
it('should handle single metric param', () => {
|
||||
const func = gfunc.createFuncInstance('sumSeries');
|
||||
expect(func.render('hello.metric')).toEqual('sumSeries(hello.metric)');
|
||||
});
|
||||
|
||||
it('should include default params if options enable it', function() {
|
||||
it('should include default params if options enable it', () => {
|
||||
const func = gfunc.createFuncInstance('scaleToSeconds', {
|
||||
withDefaultParams: true,
|
||||
});
|
||||
expect(func.render('hello')).toEqual('scaleToSeconds(hello, 1)');
|
||||
});
|
||||
|
||||
it('should handle int or interval params with number', function() {
|
||||
it('should handle int or interval params with number', () => {
|
||||
const func = gfunc.createFuncInstance('movingMedian');
|
||||
func.params[0] = '5';
|
||||
expect(func.render('hello')).toEqual('movingMedian(hello, 5)');
|
||||
});
|
||||
|
||||
it('should handle int or interval params with interval string', function() {
|
||||
it('should handle int or interval params with interval string', () => {
|
||||
const func = gfunc.createFuncInstance('movingMedian');
|
||||
func.params[0] = '5min';
|
||||
expect(func.render('hello')).toEqual("movingMedian(hello, '5min')");
|
||||
});
|
||||
|
||||
it('should never quote boolean paramater', function() {
|
||||
it('should never quote boolean paramater', () => {
|
||||
const func = gfunc.createFuncInstance('sortByName');
|
||||
func.params[0] = '$natural';
|
||||
expect(func.render('hello')).toEqual('sortByName(hello, $natural)');
|
||||
});
|
||||
|
||||
it('should never quote int paramater', function() {
|
||||
it('should never quote int paramater', () => {
|
||||
const func = gfunc.createFuncInstance('maximumAbove');
|
||||
func.params[0] = '$value';
|
||||
expect(func.render('hello')).toEqual('maximumAbove(hello, $value)');
|
||||
});
|
||||
|
||||
it('should never quote node paramater', function() {
|
||||
it('should never quote node paramater', () => {
|
||||
const func = gfunc.createFuncInstance('aliasByNode');
|
||||
func.params[0] = '$node';
|
||||
expect(func.render('hello')).toEqual('aliasByNode(hello, $node)');
|
||||
});
|
||||
|
||||
it('should handle metric param and int param and string param', function() {
|
||||
it('should handle metric param and int param and string param', () => {
|
||||
const func = gfunc.createFuncInstance('groupByNode');
|
||||
func.params[0] = 5;
|
||||
func.params[1] = 'avg';
|
||||
expect(func.render('hello.metric')).toEqual("groupByNode(hello.metric, 5, 'avg')");
|
||||
});
|
||||
|
||||
it('should handle function with no metric param', function() {
|
||||
it('should handle function with no metric param', () => {
|
||||
const func = gfunc.createFuncInstance('randomWalk');
|
||||
func.params[0] = 'test';
|
||||
expect(func.render(undefined)).toEqual("randomWalk('test')");
|
||||
});
|
||||
|
||||
it('should handle function multiple series params', function() {
|
||||
it('should handle function multiple series params', () => {
|
||||
const func = gfunc.createFuncInstance('asPercent');
|
||||
func.params[0] = '#B';
|
||||
expect(func.render('#A')).toEqual('asPercent(#A, #B)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when requesting function definitions', function() {
|
||||
it('should return function definitions', function() {
|
||||
describe('when requesting function definitions', () => {
|
||||
it('should return function definitions', () => {
|
||||
const funcIndex = gfunc.getFuncDefs('1.0');
|
||||
expect(Object.keys(funcIndex).length).toBeGreaterThan(8);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when updating func param', function() {
|
||||
it('should update param value and update text representation', function() {
|
||||
describe('when updating func param', () => {
|
||||
it('should update param value and update text representation', () => {
|
||||
const func = gfunc.createFuncInstance('summarize', {
|
||||
withDefaultParams: true,
|
||||
});
|
||||
@@ -110,21 +110,21 @@ describe('when updating func param', function() {
|
||||
expect(func.text).toBe('summarize(1h, sum, false)');
|
||||
});
|
||||
|
||||
it('should parse numbers as float', function() {
|
||||
it('should parse numbers as float', () => {
|
||||
const func = gfunc.createFuncInstance('scale');
|
||||
func.updateParam('0.001', 0);
|
||||
expect(func.params[0]).toBe('0.001');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when updating func param with optional second parameter', function() {
|
||||
it('should update value and text', function() {
|
||||
describe('when updating func param with optional second parameter', () => {
|
||||
it('should update value and text', () => {
|
||||
const func = gfunc.createFuncInstance('aliasByNode');
|
||||
func.updateParam('1', 0);
|
||||
expect(func.params[0]).toBe('1');
|
||||
});
|
||||
|
||||
it('should slit text and put value in second param', function() {
|
||||
it('should slit text and put value in second param', () => {
|
||||
const func = gfunc.createFuncInstance('aliasByNode');
|
||||
func.updateParam('4,-5', 0);
|
||||
expect(func.params[0]).toBe('4');
|
||||
@@ -132,7 +132,7 @@ describe('when updating func param with optional second parameter', function() {
|
||||
expect(func.text).toBe('aliasByNode(4, -5)');
|
||||
});
|
||||
|
||||
it('should remove second param when empty string is set', function() {
|
||||
it('should remove second param when empty string is set', () => {
|
||||
const func = gfunc.createFuncInstance('aliasByNode');
|
||||
func.updateParam('4,-5', 0);
|
||||
func.updateParam('', 1);
|
||||
|
||||
Reference in New Issue
Block a user