DataSourcesListPage.test.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import React from 'react';
  2. import { shallow } from 'enzyme';
  3. import { DataSourcesListPage, Props } from './DataSourcesListPage';
  4. import { DataSource, NavModel } from 'app/types';
  5. import { LayoutModes } from '../../core/components/LayoutSelector/LayoutSelector';
  6. import { getMockDataSources } from './__mocks__/dataSourcesMocks';
  7. const setup = (propOverrides?: object) => {
  8. const props: Props = {
  9. dataSources: [] as DataSource[],
  10. layoutMode: LayoutModes.Grid,
  11. loadDataSources: jest.fn(),
  12. navModel: {
  13. main: {
  14. text: 'Configuration'
  15. },
  16. node: {
  17. text: 'Data Sources'
  18. }
  19. } as NavModel,
  20. dataSourcesCount: 0,
  21. searchQuery: '',
  22. setDataSourcesSearchQuery: jest.fn(),
  23. setDataSourcesLayoutMode: jest.fn(),
  24. hasFetched: false,
  25. };
  26. Object.assign(props, propOverrides);
  27. return shallow(<DataSourcesListPage {...props} />);
  28. };
  29. describe('Render', () => {
  30. it('should render component', () => {
  31. const wrapper = setup();
  32. expect(wrapper).toMatchSnapshot();
  33. });
  34. it('should render action bar and datasources', () => {
  35. const wrapper = setup({
  36. dataSources: getMockDataSources(5),
  37. dataSourcesCount: 5,
  38. hasFetched: true,
  39. });
  40. expect(wrapper).toMatchSnapshot();
  41. });
  42. });