{
expect(onClickHandler).toBeCalled();
});
});
+
+ test('is disabled', () => {
+ const component = render(Click Me);
+
+ expect(component).toMatchSnapshot();
+ });
});
});
diff --git a/src/components/text/__snapshots__/text_align.test.tsx.snap b/src/components/text/__snapshots__/text_align.test.tsx.snap
index 7f40c0ee1ee..8853021b7dc 100644
--- a/src/components/text/__snapshots__/text_align.test.tsx.snap
+++ b/src/components/text/__snapshots__/text_align.test.tsx.snap
@@ -1,5 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`EuiTextAlign direction prop center is rendered 1`] = `
+
+`;
+
+exports[`EuiTextAlign direction prop left is rendered 1`] = `
+
+`;
+
+exports[`EuiTextAlign direction prop right is rendered 1`] = `
+
+`;
+
exports[`EuiTextAlign is rendered 1`] = `
{
test('is rendered', () => {
@@ -10,4 +10,14 @@ describe('EuiTextAlign', () => {
expect(component).toMatchSnapshot();
});
+
+ describe('direction prop', () => {
+ ALIGNMENTS.forEach(direction => {
+ test(`${direction} is rendered`, () => {
+ const component = render();
+
+ expect(component).toMatchSnapshot();
+ });
+ });
+ });
});
diff --git a/src/components/toggle/__snapshots__/toggle.test.tsx.snap b/src/components/toggle/__snapshots__/toggle.test.tsx.snap
index 0b074772d8a..633f9960588 100644
--- a/src/components/toggle/__snapshots__/toggle.test.tsx.snap
+++ b/src/components/toggle/__snapshots__/toggle.test.tsx.snap
@@ -13,3 +13,59 @@ exports[`EuiToggle is rendered 1`] = `
/>
`;
+
+exports[`EuiToggle props checked is rendered 1`] = `
+
+
+
+`;
+
+exports[`EuiToggle props isDisabled is rendered 1`] = `
+
+
+
+`;
+
+exports[`EuiToggle props onChange is rendered 1`] = `
+
+
+
+`;
+
+exports[`EuiToggle props type is rendered 1`] = `
+
+
+
+`;
diff --git a/src/components/toggle/toggle.test.tsx b/src/components/toggle/toggle.test.tsx
index 95b5f4ef27c..1c89f79c0a9 100644
--- a/src/components/toggle/toggle.test.tsx
+++ b/src/components/toggle/toggle.test.tsx
@@ -12,4 +12,45 @@ describe('EuiToggle', () => {
expect(component).toMatchSnapshot();
});
+
+ describe('props', () => {
+ test('isDisabled is rendered', () => {
+ const component = render();
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('onChange is rendered', () => {
+ const component = render(
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('type is rendered', () => {
+ const component = render(
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('checked is rendered', () => {
+ const component = render(
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+ });
});
diff --git a/src/components/tree_view/tree_view.test.tsx b/src/components/tree_view/tree_view.test.tsx
index a6c72de6667..3112a114e12 100644
--- a/src/components/tree_view/tree_view.test.tsx
+++ b/src/components/tree_view/tree_view.test.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { EuiIcon } from '../icon';
import { EuiToken } from '../token';
-import { render } from 'enzyme';
+import { render, shallow } from 'enzyme';
import { requiredProps } from '../../test/required_props';
import { EuiTreeView } from './tree_view';
@@ -11,71 +11,109 @@ jest.mock('../../services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => () => 'htmlId',
}));
-describe('EuiTreeView', () => {
- test('is rendered', () => {
- const component = render(
- ,
+ iconWhenExpanded: ,
+ isExpanded: true,
+ children: [
+ {
+ label: 'Item A',
+ id: 'item_a',
+ icon: ,
+ },
+ {
+ label: 'Item B',
+ id: 'item_b',
+ icon: ,
+ iconWhenExpanded: ,
+ children: [
{
- label: 'Item One',
- id: 'item_one',
- icon: ,
- iconWhenExpanded: ,
- isExpanded: true,
- children: [
- {
- label: 'Item A',
- id: 'item_a',
- icon: ,
- },
- {
- label: 'Item B',
- id: 'item_b',
- icon: ,
- iconWhenExpanded: ,
- children: [
- {
- label: 'A Cloud',
- id: 'item_cloud',
- icon: ,
- },
- {
- label: "I'm a Bug",
- id: 'item_bug',
- icon: ,
- className: 'classForBug',
- },
- ],
- },
- {
- label: 'Item C',
- id: 'item_c',
- icon: ,
- iconWhenExpanded: ,
- children: [
- {
- label: 'Another Cloud',
- id: 'item_cloud2',
- icon: ,
- },
- {
- label: 'Another Bug',
- id: 'item_bug2',
- icon: ,
- },
- ],
- },
- ],
+ label: 'A Cloud',
+ id: 'item_cloud',
+ icon: ,
},
{
- label: 'Item Two',
- id: 'item_two',
+ label: "I'm a Bug",
+ id: 'item_bug',
+ icon: ,
+ className: 'classForBug',
},
- ]}
- {...requiredProps}
- />
- );
+ ],
+ },
+ {
+ label: 'Item C',
+ id: 'item_c',
+ icon: ,
+ iconWhenExpanded: ,
+ children: [
+ {
+ label: 'Another Cloud',
+ id: 'item_cloud2',
+ icon: ,
+ },
+ {
+ label: 'Another Bug',
+ id: 'item_bug2',
+ icon: ,
+ },
+ ],
+ },
+ ],
+ },
+ {
+ label: 'Item Two',
+ id: 'item_two',
+ },
+];
+
+describe('EuiTreeView', () => {
+ test('is rendered', () => {
+ const component = render();
expect(component).toMatchSnapshot();
});
+
+ test('length of open items', () => {
+ const component = shallow(
+
+ );
+ const instance = component.instance();
+
+ expect(component.state('openItems')).toHaveLength(1);
+
+ instance.handleNodeClick(items[1]);
+ expect(component.state('openItems')).toHaveLength(2);
+ });
+
+ test('activeItem changes', () => {
+ const component = shallow(
+
+ );
+ const instance = component.instance();
+
+ expect(component.state('activeItem')).toBe('');
+
+ instance.handleNodeClick(items[1]);
+ expect(component.state('activeItem')).toBe('item_two');
+ });
+
+ test('open node changes', () => {
+ const component = shallow(
+
+ );
+ const instance = component.instance();
+
+ expect(instance.isNodeOpen(items[1])).toBe(false);
+
+ instance.handleNodeClick(items[1]);
+ expect(instance.isNodeOpen(items[1])).toBe(true);
+
+ expect(instance.isNodeOpen(items[0])).toBe(true);
+
+ instance.handleNodeClick(items[0]);
+ expect(instance.isNodeOpen(items[0])).toBe(false);
+ });
});