DataSourcesListPage.test.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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: {} as NavModel,
  13. dataSourcesCount: 0,
  14. searchQuery: '',
  15. setDataSourcesSearchQuery: jest.fn(),
  16. setDataSourcesLayoutMode: jest.fn(),
  17. hasFetched: false,
  18. };
  19. Object.assign(props, propOverrides);
  20. return shallow(<DataSourcesListPage {...props} />);
  21. };
  22. describe('Render', () => {
  23. it('should render component', () => {
  24. const wrapper = setup();
  25. expect(wrapper).toMatchSnapshot();
  26. });
  27. it('should render action bar and datasources', () => {
  28. const wrapper = setup({
  29. dataSources: getMockDataSources(5),
  30. dataSourcesCount: 5,
  31. hasFetched: true,
  32. });
  33. expect(wrapper).toMatchSnapshot();
  34. });
  35. });