DataSourcesListPage.test.tsx 1016 B

12345678910111213141516171819202122232425262728293031323334353637
  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. };
  15. Object.assign(props, propOverrides);
  16. return shallow(<DataSourcesListPage {...props} />);
  17. };
  18. describe('Render', () => {
  19. it('should render component', () => {
  20. const wrapper = setup();
  21. expect(wrapper).toMatchSnapshot();
  22. });
  23. it('should render action bar and datasources', () => {
  24. const wrapper = setup({
  25. dataSources: getMockDataSources(5),
  26. dataSourcesCount: 5,
  27. });
  28. expect(wrapper).toMatchSnapshot();
  29. });
  30. });