Files
grafana/public/app/features/datasources/components/picker/utils.test.ts
Ivan Ortega Alba c7af53b79f [Under FF] New DS Picker with advance mode (#66566)
* Add a wrapper to switch between the previous and new DS picker depending on the feature toggle advancedDataSourcePicker.

* Add a new component to represent the modal DS picker, which we will refer as advanced DS picker
Integrate this into the Edit panel, for now, until we're ready to replace everywhere the grafana-runtime DS picker by the wrapper.

* Replace Drawer component with the dropdown

* Adjust the first version of the styles to fit into this Figma design

* Adjust the design of the FileDropzoneDefaultChildren to match with the new DS modal but everywhere else is used nowadays.

---------

Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
2023-04-19 16:08:09 +03:00

31 lines
1.4 KiB
TypeScript

import { DataSourceInstanceSettings, DataSourceRef } from '@grafana/data';
import { isDataSourceMatch } from './utils';
describe('isDataSourceMatch', () => {
const dataSourceInstanceSettings = { uid: 'a' } as DataSourceInstanceSettings;
it('matches a string with the uid', () => {
expect(isDataSourceMatch(dataSourceInstanceSettings, 'a')).toBeTruthy();
});
it('matches a datasource with a datasource by the uid', () => {
expect(isDataSourceMatch(dataSourceInstanceSettings, { uid: 'a' } as DataSourceInstanceSettings)).toBeTruthy();
});
it('matches a datasource ref with a datasource by the uid', () => {
expect(isDataSourceMatch(dataSourceInstanceSettings, { uid: 'a' } as DataSourceRef)).toBeTruthy();
});
it('doesnt match with null', () => {
expect(isDataSourceMatch(dataSourceInstanceSettings, null)).toBeFalsy();
});
it('doesnt match a datasource to a non matching string', () => {
expect(isDataSourceMatch(dataSourceInstanceSettings, 'b')).toBeFalsy();
});
it('doesnt match a datasource with a different datasource uid', () => {
expect(isDataSourceMatch(dataSourceInstanceSettings, { uid: 'b' } as DataSourceInstanceSettings)).toBeFalsy();
});
it('doesnt match a datasource with a datasource ref with a different uid', () => {
expect(isDataSourceMatch(dataSourceInstanceSettings, { uid: 'b' } as DataSourceRef)).toBeFalsy();
});
});