From 64eace96c0a3b62895525be1ce4cd59897bfb7c0 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Tue, 25 Sep 2018 16:50:13 +0200 Subject: [PATCH] first test --- .../features/plugins/PluginListPage.test.tsx | 31 +++++++++++++++++++ .../app/features/plugins/PluginListPage.tsx | 2 +- .../PluginListPage.test.tsx.snap | 21 +++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 public/app/features/plugins/PluginListPage.test.tsx create mode 100644 public/app/features/plugins/__snapshots__/PluginListPage.test.tsx.snap diff --git a/public/app/features/plugins/PluginListPage.test.tsx b/public/app/features/plugins/PluginListPage.test.tsx new file mode 100644 index 00000000000..830d1176eae --- /dev/null +++ b/public/app/features/plugins/PluginListPage.test.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import { PluginListPage, Props } from './PluginListPage'; +import { NavModel, Plugin } from '../../types'; + +const setup = (propOverrides?: object) => { + const props: Props = { + navModel: {} as NavModel, + plugins: [] as Plugin[], + layoutMode: 'grid', + loadPlugins: jest.fn(), + }; + + Object.assign(props, propOverrides); + + const wrapper = shallow(); + const instance = wrapper.instance() as PluginListPage; + + return { + wrapper, + instance, + }; +}; + +describe('Render', () => { + it('should render component', () => { + const { wrapper } = setup(); + + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/public/app/features/plugins/PluginListPage.tsx b/public/app/features/plugins/PluginListPage.tsx index a2b0348aefd..358eb4a7887 100644 --- a/public/app/features/plugins/PluginListPage.tsx +++ b/public/app/features/plugins/PluginListPage.tsx @@ -9,7 +9,7 @@ import { loadPlugins } from './state/actions'; import { getNavModel } from '../../core/selectors/navModel'; import { getLayoutMode, getPlugins } from './state/selectors'; -interface Props { +export interface Props { navModel: NavModel; plugins: Plugin[]; layoutMode: string; diff --git a/public/app/features/plugins/__snapshots__/PluginListPage.test.tsx.snap b/public/app/features/plugins/__snapshots__/PluginListPage.test.tsx.snap new file mode 100644 index 00000000000..cb8c79bbcee --- /dev/null +++ b/public/app/features/plugins/__snapshots__/PluginListPage.test.tsx.snap @@ -0,0 +1,21 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Render should render component 1`] = ` +
+ +
+ + +
+
+`;