Commit 0280179d by Erik Sundell

stackdriver: add tests for render snapshop and default query type

parent 7bdf97d3
...@@ -3,15 +3,30 @@ import renderer from 'react-test-renderer'; ...@@ -3,15 +3,30 @@ import renderer from 'react-test-renderer';
import { StackdriverTemplateQueryComponent } from './TemplateQueryComponent'; import { StackdriverTemplateQueryComponent } from './TemplateQueryComponent';
import { TemplateQueryProps } from 'app/types/plugins'; import { TemplateQueryProps } from 'app/types/plugins';
describe('StackdriverTemplateQueryComponent', () => { jest.mock('../functions', () => ({
const props: TemplateQueryProps = { getMetricTypes: () => Promise.resolve({ metricTypes: [], selectedMetricType: '' }),
onChange: (query, definition) => {}, extractServicesFromMetricDescriptors: m => m,
query: '', }));
datasource: {},
}; const props: TemplateQueryProps = {
onChange: (query, definition) => {},
query: '',
datasource: {
getMetricTypes: async p => [],
},
};
describe('StackdriverTemplateQueryComponent', () => {
it('renders correctly', () => { it('renders correctly', () => {
const tree = renderer.create(<StackdriverTemplateQueryComponent {...props} />).toJSON(); const tree = renderer.create(<StackdriverTemplateQueryComponent {...props} />).toJSON();
expect(tree).toMatchSnapshot(); 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 - Services');
done();
};
renderer.create(<StackdriverTemplateQueryComponent {...props} />).toJSON();
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment