runSharedRequest.test.ts 696 B

1234567891011121314151617181920212223
  1. import { DataSourceApi } from '@grafana/data';
  2. import { isSharedDashboardQuery } from './runSharedRequest';
  3. describe('SharedQueryRunner', () => {
  4. it('should identify shared queries', () => {
  5. expect(isSharedDashboardQuery('-- Dashboard --')).toBe(true);
  6. expect(isSharedDashboardQuery('')).toBe(false);
  7. expect(isSharedDashboardQuery(undefined as unknown as null)).toBe(false);
  8. expect(isSharedDashboardQuery(null)).toBe(false);
  9. const ds = {
  10. meta: {
  11. name: '-- Dashboard --',
  12. },
  13. } as DataSourceApi;
  14. expect(isSharedDashboardQuery(ds)).toBe(true);
  15. ds.meta!.name = 'something else';
  16. expect(isSharedDashboardQuery(ds)).toBe(false);
  17. });
  18. });