-
Notifications
You must be signed in to change notification settings - Fork 11.7k
/
DataSourcesList.test.tsx
49 lines (38 loc) · 1.51 KB
/
DataSourcesList.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { render, screen } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import { configureStore } from 'app/store/configureStore';
import { getMockDataSources } from '../__mocks__';
import { DataSourcesListView } from './DataSourcesList';
const setup = () => {
const store = configureStore();
return render(
<Provider store={store}>
<DataSourcesListView
dataSources={getMockDataSources(3)}
dataSourcesCount={3}
isLoading={false}
hasCreateRights={true}
/>
</Provider>
);
};
describe('<DataSourcesList>', () => {
it('should render action bar', async () => {
setup();
expect(await screen.findByPlaceholderText('Search by name or type')).toBeInTheDocument();
expect(await screen.findByRole('combobox', { name: 'Sort' })).toBeInTheDocument();
});
it('should render list of datasources', async () => {
setup();
expect(await screen.findAllByRole('listitem')).toHaveLength(3);
expect(await screen.findAllByRole('heading')).toHaveLength(3);
expect(await screen.findAllByRole('link', { name: 'Build a Dashboard' })).toHaveLength(3);
expect(await screen.findAllByRole('link', { name: 'Explore' })).toHaveLength(3);
});
it('should render all elements in the list item', async () => {
setup();
expect(await screen.findByRole('heading', { name: 'dataSource-0' })).toBeInTheDocument();
expect(await screen.findByRole('link', { name: 'dataSource-0' })).toBeInTheDocument();
});
});