Files
grafana/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/InsightsConfig.test.tsx
Shavonn Brown f22aaa5518 Azure Monitor and Log Analytics converted and separated into components (#18259)
* Azure Monitor and Log Analytics converted and separated into components

* Insights creds converted

* remove angular config

* fix workspaces and missing sameas key

* fix workspace save

* set subscriptionId key

* editor fields, load workspaces btn

* workspace load req fields updated

* added tooltip to switch, disable buttons instead of hide

* master merge and tests
2019-08-19 23:35:44 +02:00

85 lines
2.1 KiB
TypeScript

import React from 'react';
import { shallow } from 'enzyme';
import InsightsConfig, { Props } from './InsightsConfig';
const setup = (propOverrides?: object) => {
const props: Props = {
datasourceConfig: {
id: 21,
orgId: 1,
name: 'Azure Monitor-10-10',
type: 'grafana-azure-monitor-datasource',
typeLogoUrl: '',
access: 'proxy',
url: '',
password: '',
user: '',
database: '',
basicAuth: false,
basicAuthUser: '',
basicAuthPassword: '',
withCredentials: false,
isDefault: false,
jsonData: {},
secureJsonFields: {
appInsightsApiKey: false,
},
editorJsonData: {
appInsightsAppId: 'cddcc020-2c94-460a-a3d0-df3147ffa792',
},
editorSecureJsonData: {
appInsightsApiKey: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
},
version: 1,
readOnly: false,
},
onDatasourceUpdate: jest.fn(),
};
Object.assign(props, propOverrides);
return shallow(<InsightsConfig {...props} />);
};
describe('Render', () => {
it('should render component', () => {
const wrapper = setup();
expect(wrapper).toMatchSnapshot();
});
it('should disable insights api key input', () => {
const wrapper = setup({
datasourceConfig: {
secureJsonFields: {
appInsightsApiKey: true,
},
editorJsonData: {
appInsightsAppId: 'cddcc020-2c94-460a-a3d0-df3147ffa792',
},
editorSecureJsonData: {
appInsightsApiKey: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
},
},
});
expect(wrapper).toMatchSnapshot();
});
it('should enable insights api key input', () => {
const wrapper = setup({
datasourceConfig: {
secureJsonFields: {
appInsightsApiKey: false,
},
editorJsonData: {
appInsightsAppId: 'cddcc020-2c94-460a-a3d0-df3147ffa792',
},
editorSecureJsonData: {
appInsightsApiKey: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
},
},
});
expect(wrapper).toMatchSnapshot();
});
});