From f7fe4d486567987cc1a97b2b46089ac233914b01 Mon Sep 17 00:00:00 2001 From: Lukas Siatka Date: Mon, 27 Jan 2020 04:00:11 +0000 Subject: [PATCH] Explore: adds MetaInfoText tests --- .../features/explore/MetaInfoText.test.tsx | 34 +++++++++++++++++++ .../__snapshots__/MetaInfoText.test.tsx.snap | 18 ++++++++++ 2 files changed, 52 insertions(+) create mode 100644 public/app/features/explore/MetaInfoText.test.tsx create mode 100644 public/app/features/explore/__snapshots__/MetaInfoText.test.tsx.snap diff --git a/public/app/features/explore/MetaInfoText.test.tsx b/public/app/features/explore/MetaInfoText.test.tsx new file mode 100644 index 00000000000..b5e55197d95 --- /dev/null +++ b/public/app/features/explore/MetaInfoText.test.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { shallow, render } from 'enzyme'; +import { MetaInfoText, MetaItemProps } from './MetaInfoText'; +describe('MetaInfoText', () => { + it('should render component', () => { + const items: MetaItemProps[] = [ + { label: 'label', value: 'value' }, + { label: 'label2', value: 'value2' }, + ]; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + }); + + it('should render items', () => { + const items: MetaItemProps[] = [ + { label: 'label', value: 'value' }, + { label: 'label2', value: 'value2' }, + ]; + + const wrapper = render(); + expect(wrapper.find('label')).toBeTruthy(); + expect(wrapper.find('value')).toBeTruthy(); + expect(wrapper.find('label2')).toBeTruthy(); + expect(wrapper.find('value2')).toBeTruthy(); + }); + + it('should render no items when the array is empty', () => { + const items: MetaItemProps[] = []; + + const wrapper = shallow(); + expect(wrapper.find('div').exists()).toBeTruthy(); + expect(wrapper.find('div').children()).toHaveLength(0); + }); +}); diff --git a/public/app/features/explore/__snapshots__/MetaInfoText.test.tsx.snap b/public/app/features/explore/__snapshots__/MetaInfoText.test.tsx.snap new file mode 100644 index 00000000000..9407f3d2d39 --- /dev/null +++ b/public/app/features/explore/__snapshots__/MetaInfoText.test.tsx.snap @@ -0,0 +1,18 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`MetaInfoText should render component 1`] = ` +
+ + +
+`;