grafana/public/app/features/datasources/state/buildCategories.test.ts
Brendan O'Handley 5b52a1c391
List Azure Devops as an enterprise plugin (#49189)
* list azure devops as an enterprise plugin

* change base url to grafana.com/grafana/plugins and remove trailing slashes for consistency
2022-05-18 15:02:45 -04:00

59 lines
1.6 KiB
TypeScript

import { DataSourcePluginMeta } from '@grafana/data';
import { getMockPlugin } from '../../plugins/__mocks__/pluginMocks';
import { buildCategories } from './buildCategories';
const plugins: DataSourcePluginMeta[] = [
{
...getMockPlugin({ id: 'graphite' }),
category: 'tsdb',
},
{
...getMockPlugin({ id: 'prometheus' }),
category: 'tsdb',
},
{
...getMockPlugin({ id: 'elasticsearch' }),
category: 'logging',
},
{
...getMockPlugin({ id: 'loki' }),
category: 'logging',
},
{
...getMockPlugin({ id: 'azure' }),
category: 'cloud',
},
];
describe('buildCategories', () => {
const categories = buildCategories(plugins);
it('should group plugins into categories and remove empty categories', () => {
expect(categories.length).toBe(4);
expect(categories[0].title).toBe('Time series databases');
expect(categories[0].plugins.length).toBe(2);
expect(categories[1].title).toBe('Logging & document databases');
});
it('should sort plugins according to hard coded sorting rules', () => {
expect(categories[1].plugins[0].id).toBe('loki');
});
it('should add phantom plugin for Grafana cloud', () => {
expect(categories[2].title).toBe('Cloud');
expect(categories[2].plugins.length).toBe(2);
expect(categories[2].plugins[1].id).toBe('gcloud');
});
it('should set module to phantom on phantom plugins', () => {
expect(categories[3].plugins[0].module).toBe('phantom');
});
it('should add enterprise phantom plugins', () => {
expect(categories[3].title).toBe('Enterprise plugins');
expect(categories[3].plugins.length).toBe(17);
});
});