/usr/share/grafana/public/app/plugins/datasource/graphite
import gfunc, { FuncDefs, FuncInstance } from './gfunc'; describe('gfunc', () => { const INDEX: FuncDefs = { foo: { name: 'foo', params: [], defaultParams: [], }, }; it('returns function from the index', () => { expect(gfunc.getFuncDef('foo', INDEX)).toEqual(INDEX.foo); }); it('marks function as unknown when it is not available in the index', () => { expect(gfunc.getFuncDef('bar', INDEX)).toEqual({ name: 'bar', params: [{ name: '', type: '', multiple: true }], defaultParams: [''], unknown: true, }); }); it('renders the version < .9 asPercent function parameters by not escaping them as a string', () => { // this function is returned from the graphite functions endpoint const asPercentDef = { name: 'asPercent', description: 'Calculates a percentage.', category: 'Combine', params: [ { name: 'total', type: 'string', optional: true, multiple: false, }, { name: 'nodes', type: 'node_or_tag', optional: true, multiple: true, options: [], }, ], defaultParams: [], }; const asPercent = new FuncInstance(asPercentDef); const asPercentRendered = asPercent.render('#A', () => '#A'); expect(asPercentRendered).toEqual('asPercent(#A)'); }); });
.
Edit
..
Edit
CHANGELOG.md
Edit
README.md
Edit
components
Edit
configuration
Edit
dashboards
Edit
datasource.test.ts
Edit
datasource.ts
Edit
datasource_integration.test.ts
Edit
dist
Edit
gfunc.test.ts
Edit
gfunc.ts
Edit
graphite_query.ts
Edit
img
Edit
jest-setup.js
Edit
jest.config.js
Edit
lexer.ts
Edit
meta.test.ts
Edit
meta.ts
Edit
migrations.ts
Edit
module.ts
Edit
package.json
Edit
parser.ts
Edit
plugin.json
Edit
project.json
Edit
query_help.md
Edit
specs
Edit
state
Edit
tsconfig.json
Edit
types.ts
Edit
utils.test.ts
Edit
utils.ts
Edit
versions.ts
Edit
webpack.config.ts
Edit