2020-01-06 09:56:34 -06:00
|
|
|
import { buildCategories } from './buildCategories';
|
|
|
|
import { getMockPlugin } from '../../plugins/__mocks__/pluginMocks';
|
|
|
|
import { DataSourcePluginMeta } from '@grafana/data';
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2020-10-28 02:15:32 -05:00
|
|
|
it('should group plugins into categories and remove empty categories', () => {
|
|
|
|
expect(categories.length).toBe(4);
|
2020-01-06 09:56:34 -06:00
|
|
|
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', () => {
|
2020-10-28 02:15:32 -05:00
|
|
|
expect(categories[2].title).toBe('Cloud');
|
|
|
|
expect(categories[2].plugins.length).toBe(2);
|
|
|
|
expect(categories[2].plugins[1].id).toBe('gcloud');
|
2020-01-06 09:56:34 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should set module to phantom on phantom plugins', () => {
|
2020-10-28 02:15:32 -05:00
|
|
|
expect(categories[3].plugins[0].module).toBe('phantom');
|
2020-01-06 09:56:34 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should add enterprise phantom plugins', () => {
|
2020-10-28 02:15:32 -05:00
|
|
|
expect(categories[3].title).toBe('Enterprise plugins');
|
2021-08-04 10:08:43 -05:00
|
|
|
expect(categories[3].plugins.length).toBe(16);
|
2020-01-06 09:56:34 -06:00
|
|
|
});
|
|
|
|
});
|