mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* MVP of a new datasource picker * Add datasource select history, naming DatasourceSelect -> DataSourceDrawer * refactor cards * Cleanup and fixing sort order for recents * add feature flag * fix feature flag name and use it * Highlight selected * Move new ds picker to core * Restore original datasource picker * Remove unused property * update yarn.lock * Rename folder, update codeowners * add test for util functions * Remove es-lint exception * Change feature toggle description * remove unnecessary if Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com> * Make test a bit more clear Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com> * Clean up api, filter once and before maps, minor code cleanup * Fix prettier issue --------- Co-authored-by: Ivan Ortega Alba <ivanortegaalba@gmail.com>
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { DataSourceInstanceSettings } from '@grafana/data';
|
|
import { DataSourceJsonData, DataSourceRef } from '@grafana/schema';
|
|
|
|
import { isDataSourceMatch } from './DataSourceDrawer';
|
|
|
|
describe('DataSourceDrawer', () => {
|
|
describe('isDataSourceMatch', () => {
|
|
const dataSourceInstanceSettings = { uid: 'a' } as DataSourceInstanceSettings<DataSourceJsonData>;
|
|
|
|
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<DataSourceJsonData>)
|
|
).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<DataSourceJsonData>)
|
|
).toBeFalsy();
|
|
});
|
|
it('doesnt match a datasource with a datasource ref with a different uid', () => {
|
|
expect(isDataSourceMatch(dataSourceInstanceSettings, { uid: 'b' } as DataSourceRef)).toBeFalsy();
|
|
});
|
|
});
|
|
});
|