The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.test...

31 lines
1011 B

import React from 'react';
import renderer from 'react-test-renderer';
import { StackdriverTemplateQueryComponent } from './TemplateQueryComponent';
import { TemplateQueryProps } from 'app/types/plugins';
jest.mock('../functions', () => ({
getMetricTypes: async () => ({ metricTypes: [], selectedMetricType: '' }),
}));
const props: TemplateQueryProps = {
onChange: (query, definition) => {},
query: '',
datasource: {
getMetricTypes: async p => [],
},
};
describe('StackdriverTemplateQueryComponent', () => {
it('renders correctly', () => {
const tree = renderer.create(<StackdriverTemplateQueryComponent {...props} />).toJSON();
expect(tree).toMatchSnapshot();
});
it('should use the first query type in the array if no query type was saved before', done => {
props.onChange = (query, definition) => {
expect(definition).toBe('Stackdriver - Metric Types');
done();
};
renderer.create(<StackdriverTemplateQueryComponent {...props} />).toJSON();
});
});