test: Add jest-enzyme assertion library for better frontend tests (#10459)

* adding jest-enzyme

* enzymeify lots of assertions

* types for jest-enzyme
This commit is contained in:
David Aaron Suddjian
2020-07-29 10:53:06 -07:00
committed by GitHub
parent 671461d0d0
commit 7f70a241f9
111 changed files with 1074 additions and 315 deletions

View File

@@ -34,6 +34,6 @@ describe('CodeModal', () => {
wrappingComponent: ThemeProvider,
wrappingComponentProps: { theme: supersetTheme },
});
expect(wrapper.find('.fa-edit')).toHaveLength(1);
expect(wrapper.find('.fa-edit')).toExist();
});
});

View File

@@ -30,6 +30,6 @@ describe('CssEditor', () => {
});
it('renders the trigger node', () => {
const wrapper = mount(<CssEditor {...mockedProps} />);
expect(wrapper.find('.fa-edit')).toHaveLength(1);
expect(wrapper.find('.fa-edit')).toExist();
});
});

View File

@@ -103,7 +103,7 @@ describe('DashboardBuilder', () => {
it('should render a DragDroppable DashboardHeader', () => {
const wrapper = setup(null, true);
expect(wrapper.find(DashboardHeader)).toHaveLength(1);
expect(wrapper.find(DashboardHeader)).toExist();
});
it('should render a Sticky top-level Tabs if the dashboard has tabs', () => {
@@ -150,26 +150,26 @@ describe('DashboardBuilder', () => {
it('should render a BuilderComponentPane if editMode=true and user selects "Insert Components" pane', () => {
const wrapper = setup();
expect(wrapper.find(BuilderComponentPane)).toHaveLength(0);
expect(wrapper.find(BuilderComponentPane)).not.toExist();
wrapper.setProps({
...props,
editMode: true,
builderPaneType: BUILDER_PANE_TYPE.ADD_COMPONENTS,
});
expect(wrapper.find(BuilderComponentPane)).toHaveLength(1);
expect(wrapper.find(BuilderComponentPane)).toExist();
});
it('should render a BuilderComponentPane if editMode=true and user selects "Colors" pane', () => {
const wrapper = setup();
expect(wrapper.find(BuilderComponentPane)).toHaveLength(0);
expect(wrapper.find(BuilderComponentPane)).not.toExist();
wrapper.setProps({
...props,
editMode: true,
builderPaneType: BUILDER_PANE_TYPE.COLORS,
});
expect(wrapper.find(BuilderComponentPane)).toHaveLength(1);
expect(wrapper.find(BuilderComponentPane)).toExist();
});
it('should change redux state if a top-level Tab is clicked', () => {

View File

@@ -48,7 +48,7 @@ describe('DashboardGrid', () => {
it('should render a div with class "dashboard-grid"', () => {
const wrapper = setup();
expect(wrapper.find('.dashboard-grid')).toHaveLength(1);
expect(wrapper.find('.dashboard-grid')).toExist();
});
it('should render one DashboardComponent for each gridComponent child', () => {
@@ -67,7 +67,7 @@ describe('DashboardGrid', () => {
it('should render grid column guides when resizing', () => {
const wrapper = setup({ editMode: true });
expect(wrapper.find('.grid-column-guide')).toHaveLength(0);
expect(wrapper.find('.grid-column-guide')).not.toExist();
wrapper.setState({ isResizing: true });
@@ -76,9 +76,9 @@ describe('DashboardGrid', () => {
it('should render a grid row guide when resizing', () => {
const wrapper = setup();
expect(wrapper.find('.grid-row-guide')).toHaveLength(0);
expect(wrapper.find('.grid-row-guide')).not.toExist();
wrapper.setState({ isResizing: true, rowGuideTop: 10 });
expect(wrapper.find('.grid-row-guide')).toHaveLength(1);
expect(wrapper.find('.grid-row-guide')).toExist();
});
it('should call resizeComponent when a child DashboardComponent calls resizeStop', () => {

View File

@@ -70,7 +70,7 @@ describe('Dashboard', () => {
it('should render a DashboardBuilder', () => {
const wrapper = setup();
expect(wrapper.find(DashboardBuilder)).toHaveLength(1);
expect(wrapper.find(DashboardBuilder)).toExist();
});
describe('componentWillReceiveProps', () => {

View File

@@ -45,6 +45,6 @@ describe('FilterIndicatorGroup', () => {
it('should show indicator group with badge', () => {
const wrapper = setup();
expect(wrapper.find(FilterBadgeIcon)).toHaveLength(1);
expect(wrapper.find(FilterBadgeIcon)).toExist();
});
});

View File

@@ -38,6 +38,6 @@ describe('FilterIndicatorTooltip', () => {
it('should show label', () => {
const wrapper = setup();
expect(wrapper.find(`[htmlFor="filter-tooltip-${label}"]`)).toHaveLength(1);
expect(wrapper.find(`[htmlFor="filter-tooltip-${label}"]`)).toExist();
});
});

View File

@@ -42,7 +42,7 @@ describe('FilterIndicator', () => {
it('should show indicator with badge', () => {
const wrapper = setup();
expect(wrapper.find(FilterBadgeIcon)).toHaveLength(1);
expect(wrapper.find(FilterBadgeIcon)).toExist();
});
it('should call setDirectPathToChild prop', () => {

View File

@@ -56,17 +56,17 @@ describe('FilterIndicatorsContainer', () => {
it('should not show indicator when chart is loading', () => {
const wrapper = setup({ chartStatus: 'loading' });
expect(wrapper.find(FilterIndicator)).toHaveLength(0);
expect(wrapper.find(FilterIndicator)).not.toExist();
});
it('should not show indicator for filter_box itself', () => {
const wrapper = setup({ chartId: filterId });
expect(wrapper.find(FilterIndicator)).toHaveLength(0);
expect(wrapper.find(FilterIndicator)).not.toExist();
});
it('should show indicator', () => {
const wrapper = setup();
expect(wrapper.find(FilterIndicator)).toHaveLength(1);
expect(wrapper.find(FilterIndicator)).toExist();
});
it('should not show indicator when chart is immune', () => {
@@ -83,7 +83,7 @@ describe('FilterIndicatorsContainer', () => {
},
};
const wrapper = setup({ dashboardFilters: overwriteDashboardFilters });
expect(wrapper.find(FilterIndicator)).toHaveLength(0);
expect(wrapper.find(FilterIndicator)).not.toExist();
});
it('should show single number type value', () => {
@@ -97,7 +97,7 @@ describe('FilterIndicatorsContainer', () => {
},
};
const wrapper = setup({ dashboardFilters: overwriteDashboardFilters });
expect(wrapper.find(FilterIndicator)).toHaveLength(1);
expect(wrapper.find(FilterIndicator)).toExist();
const indicatorProps = wrapper.find(FilterIndicator).first().props()
.indicator;

View File

@@ -44,8 +44,8 @@ describe('FilterTooltipWrapper', () => {
it('should contain Overlay and Tooltip', () => {
const wrapper = setup();
expect(wrapper.find(Overlay)).toHaveLength(1);
expect(wrapper.find(Tooltip)).toHaveLength(1);
expect(wrapper.find(Overlay)).toExist();
expect(wrapper.find(Tooltip)).toExist();
});
it('should show tooltip on hover', async () => {

View File

@@ -58,12 +58,12 @@ describe('HeaderActionsDropdown', () => {
it('should render the DropdownButton', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(DropdownButton)).toHaveLength(1);
expect(wrapper.find(DropdownButton)).toExist();
});
it('should not render the SaveModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(SaveModal)).toHaveLength(0);
expect(wrapper.find(SaveModal)).not.toExist();
});
it('should render two MenuItems', () => {
@@ -73,17 +73,17 @@ describe('HeaderActionsDropdown', () => {
it('should render the RefreshIntervalModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(RefreshIntervalModal)).toHaveLength(1);
expect(wrapper.find(RefreshIntervalModal)).toExist();
});
it('should render the URLShortLinkModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(URLShortLinkModal)).toHaveLength(1);
expect(wrapper.find(URLShortLinkModal)).toExist();
});
it('should not render the CssEditor', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(CssEditor)).toHaveLength(0);
expect(wrapper.find(CssEditor)).not.toExist();
});
});
@@ -92,12 +92,12 @@ describe('HeaderActionsDropdown', () => {
it('should render the DropdownButton', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(DropdownButton)).toHaveLength(1);
expect(wrapper.find(DropdownButton)).toExist();
});
it('should render the SaveModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(SaveModal)).toHaveLength(1);
expect(wrapper.find(SaveModal)).toExist();
});
it('should render three MenuItems', () => {
@@ -107,17 +107,17 @@ describe('HeaderActionsDropdown', () => {
it('should render the RefreshIntervalModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(RefreshIntervalModal)).toHaveLength(1);
expect(wrapper.find(RefreshIntervalModal)).toExist();
});
it('should render the URLShortLinkModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(URLShortLinkModal)).toHaveLength(1);
expect(wrapper.find(URLShortLinkModal)).toExist();
});
it('should not render the CssEditor', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(CssEditor)).toHaveLength(0);
expect(wrapper.find(CssEditor)).not.toExist();
});
});
@@ -126,12 +126,12 @@ describe('HeaderActionsDropdown', () => {
it('should render the DropdownButton', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(DropdownButton)).toHaveLength(1);
expect(wrapper.find(DropdownButton)).toExist();
});
it('should render the SaveModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(SaveModal)).toHaveLength(1);
expect(wrapper.find(SaveModal)).toExist();
});
it('should render three MenuItems', () => {
@@ -141,17 +141,17 @@ describe('HeaderActionsDropdown', () => {
it('should render the RefreshIntervalModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(RefreshIntervalModal)).toHaveLength(1);
expect(wrapper.find(RefreshIntervalModal)).toExist();
});
it('should render the URLShortLinkModal', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(URLShortLinkModal)).toHaveLength(1);
expect(wrapper.find(URLShortLinkModal)).toExist();
});
it('should render the CssEditor', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(CssEditor)).toHaveLength(1);
expect(wrapper.find(CssEditor)).toExist();
});
});
});

View File

@@ -93,32 +93,32 @@ describe('Header', () => {
it('should render the EditableTitle', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(EditableTitle)).toHaveLength(1);
expect(wrapper.find(EditableTitle)).toExist();
});
it('should render the PublishedStatus', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(PublishedStatus)).toHaveLength(1);
expect(wrapper.find(PublishedStatus)).toExist();
});
it('should render the FaveStar', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(FaveStar)).toHaveLength(1);
expect(wrapper.find(FaveStar)).toExist();
});
it('should render the HeaderActionsDropdown', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(HeaderActionsDropdown)).toHaveLength(1);
expect(wrapper.find(HeaderActionsDropdown)).toExist();
});
it('should render one Button', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(Button)).toHaveLength(1);
expect(wrapper.find(Button)).toExist();
});
it('should not set up undo/redo', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(UndoRedoKeylisteners)).toHaveLength(0);
expect(wrapper.find(UndoRedoKeylisteners)).not.toExist();
});
});
@@ -136,32 +136,32 @@ describe('Header', () => {
it('should render the EditableTitle', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(EditableTitle)).toHaveLength(1);
expect(wrapper.find(EditableTitle)).toExist();
});
it('should render the PublishedStatus', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(PublishedStatus)).toHaveLength(1);
expect(wrapper.find(PublishedStatus)).toExist();
});
it('should render the FaveStar', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(FaveStar)).toHaveLength(1);
expect(wrapper.find(FaveStar)).toExist();
});
it('should render the HeaderActionsDropdown', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(HeaderActionsDropdown)).toHaveLength(1);
expect(wrapper.find(HeaderActionsDropdown)).toExist();
});
it('should render one Button', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(Button)).toHaveLength(1);
expect(wrapper.find(Button)).toExist();
});
it('should not set up undo/redo', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(UndoRedoKeylisteners)).toHaveLength(0);
expect(wrapper.find(UndoRedoKeylisteners)).not.toExist();
});
});
@@ -179,22 +179,22 @@ describe('Header', () => {
it('should render the EditableTitle', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(EditableTitle)).toHaveLength(1);
expect(wrapper.find(EditableTitle)).toExist();
});
it('should render the FaveStar', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(FaveStar)).toHaveLength(1);
expect(wrapper.find(FaveStar)).toExist();
});
it('should render the PublishedStatus', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(PublishedStatus)).toHaveLength(1);
expect(wrapper.find(PublishedStatus)).toExist();
});
it('should render the HeaderActionsDropdown', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(HeaderActionsDropdown)).toHaveLength(1);
expect(wrapper.find(HeaderActionsDropdown)).toExist();
});
it('should render five Buttons', () => {
@@ -204,7 +204,7 @@ describe('Header', () => {
it('should set up undo/redo', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(UndoRedoKeylisteners)).toHaveLength(1);
expect(wrapper.find(UndoRedoKeylisteners)).toExist();
});
});
@@ -221,32 +221,32 @@ describe('Header', () => {
it('should render the EditableTitle', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(EditableTitle)).toHaveLength(1);
expect(wrapper.find(EditableTitle)).toExist();
});
it('should render the PublishedStatus', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(PublishedStatus)).toHaveLength(1);
expect(wrapper.find(PublishedStatus)).toExist();
});
it('should not render the FaveStar', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(FaveStar)).toHaveLength(0);
expect(wrapper.find(FaveStar)).not.toExist();
});
it('should render the HeaderActionsDropdown', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(HeaderActionsDropdown)).toHaveLength(1);
expect(wrapper.find(HeaderActionsDropdown)).toExist();
});
it('should render one Button', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(Button)).toHaveLength(1);
expect(wrapper.find(Button)).toExist();
});
it('should not set up undo/redo', () => {
const wrapper = setup(overrideProps);
expect(wrapper.find(UndoRedoKeylisteners)).toHaveLength(0);
expect(wrapper.find(UndoRedoKeylisteners)).not.toExist();
});
});
});

View File

@@ -29,11 +29,11 @@ describe('MissingChart', () => {
it('renders a .missing-chart-container', () => {
const wrapper = setup();
expect(wrapper.find('.missing-chart-container')).toHaveLength(1);
expect(wrapper.find('.missing-chart-container')).toExist();
});
it('renders a .missing-chart-body', () => {
const wrapper = setup();
expect(wrapper.find('.missing-chart-body')).toHaveLength(1);
expect(wrapper.find('.missing-chart-body')).toExist();
});
});

View File

@@ -37,7 +37,7 @@ describe('RefreshIntervalModal', () => {
});
it('renders the trigger node', () => {
const wrapper = mount(<RefreshIntervalModal {...mockedProps} />);
expect(wrapper.find('.fa-edit')).toHaveLength(1);
expect(wrapper.find('.fa-edit')).toExist();
});
it('should render a interval seconds', () => {
const wrapper = mount(<RefreshIntervalModal {...mockedProps} />);
@@ -59,9 +59,9 @@ describe('RefreshIntervalModal', () => {
const wrapper = shallow(<RefreshIntervalModal {...props} />);
wrapper.instance().handleFrequencyChange({ value: 30 });
expect(wrapper.find(ModalTrigger).dive().find(Alert)).toHaveLength(1);
expect(wrapper.find(ModalTrigger).dive().find(Alert)).toExist();
wrapper.instance().handleFrequencyChange({ value: 3601 });
expect(wrapper.find(ModalTrigger).dive().find(Alert)).toHaveLength(0);
expect(wrapper.find(ModalTrigger).dive().find(Alert)).not.toExist();
});
});

View File

@@ -74,7 +74,7 @@ describe('SliceAdder', () => {
it('render List', () => {
const wrapper = shallow(<SliceAdder {...props} />);
wrapper.setState({ filteredSlices: Object.values(props.slices) });
expect(wrapper.find(List)).toHaveLength(1);
expect(wrapper.find(List)).toExist();
});
it('render error', () => {

View File

@@ -47,12 +47,12 @@ describe('DragDroppable', () => {
it('should render a div with class dragdroppable', () => {
const wrapper = setup();
expect(wrapper.find('.dragdroppable')).toHaveLength(1);
expect(wrapper.find('.dragdroppable')).toExist();
});
it('should add class dragdroppable--dragging when dragging', () => {
const wrapper = setup({ isDragging: true });
expect(wrapper.find('.dragdroppable')).toHaveLength(1);
expect(wrapper.find('.dragdroppable')).toExist();
});
it('should call its child function', () => {

View File

@@ -67,12 +67,12 @@ describe('ChartHolder', () => {
it('should render a DragDroppable', () => {
const wrapper = setup();
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render a ResizableContainer', () => {
const wrapper = setup();
expect(wrapper.find(ResizableContainer)).toHaveLength(1);
expect(wrapper.find(ResizableContainer)).toExist();
});
it('should only have an adjustableWidth if its parent is a Row', () => {
@@ -98,23 +98,23 @@ describe('ChartHolder', () => {
it('should render a div with class "dashboard-component-chart-holder"', () => {
const wrapper = setup();
expect(wrapper.find('.dashboard-component-chart-holder')).toHaveLength(1);
expect(wrapper.find('.dashboard-component-chart-holder')).toExist();
});
it('should render a Chart', () => {
const wrapper = setup();
expect(wrapper.find(Chart)).toHaveLength(1);
expect(wrapper.find(Chart)).toExist();
});
it('should render a HoverMenu with DeleteComponentButton in editMode', () => {
let wrapper = setup();
expect(wrapper.find(HoverMenu)).toHaveLength(0);
expect(wrapper.find(DeleteComponentButton)).toHaveLength(0);
expect(wrapper.find(HoverMenu)).not.toExist();
expect(wrapper.find(DeleteComponentButton)).not.toExist();
// we cannot set props on the Divider because of the WithDragDropContext wrapper
wrapper = setup({ editMode: true });
expect(wrapper.find(HoverMenu)).toHaveLength(1);
expect(wrapper.find(DeleteComponentButton)).toHaveLength(1);
expect(wrapper.find(HoverMenu)).toExist();
expect(wrapper.find(DeleteComponentButton)).toExist();
});
it('should call deleteComponent when deleted', () => {

View File

@@ -66,20 +66,20 @@ describe('Chart', () => {
it('should render a SliceHeader', () => {
const wrapper = setup();
expect(wrapper.find(SliceHeader)).toHaveLength(1);
expect(wrapper.find(SliceHeader)).toExist();
});
it('should render a ChartContainer', () => {
const wrapper = setup();
expect(wrapper.find(ChartContainer)).toHaveLength(1);
expect(wrapper.find(ChartContainer)).toExist();
});
it('should render a description if it has one and isExpanded=true', () => {
const wrapper = setup();
expect(wrapper.find('.slice_description')).toHaveLength(0);
expect(wrapper.find('.slice_description')).not.toExist();
wrapper.setProps({ ...props, isExpanded: true });
expect(wrapper.find('.slice_description')).toHaveLength(1);
expect(wrapper.find('.slice_description')).toExist();
});
it('should call refreshChart when SliceHeader calls forceRefresh', () => {

View File

@@ -76,42 +76,42 @@ describe('Column', () => {
it('should render a DragDroppable', () => {
// don't count child DragDroppables
const wrapper = setup({ component: columnWithoutChildren });
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render a WithPopoverMenu', () => {
// don't count child DragDroppables
const wrapper = setup({ component: columnWithoutChildren });
expect(wrapper.find(WithPopoverMenu)).toHaveLength(1);
expect(wrapper.find(WithPopoverMenu)).toExist();
});
it('should render a ResizableContainer', () => {
// don't count child DragDroppables
const wrapper = setup({ component: columnWithoutChildren });
expect(wrapper.find(ResizableContainer)).toHaveLength(1);
expect(wrapper.find(ResizableContainer)).toExist();
});
it('should render a HoverMenu in editMode', () => {
let wrapper = setup({ component: columnWithoutChildren });
expect(wrapper.find(HoverMenu)).toHaveLength(0);
expect(wrapper.find(HoverMenu)).not.toExist();
// we cannot set props on the Row because of the WithDragDropContext wrapper
wrapper = setup({ component: columnWithoutChildren, editMode: true });
expect(wrapper.find(HoverMenu)).toHaveLength(1);
expect(wrapper.find(HoverMenu)).toExist();
});
it('should render a DeleteComponentButton in editMode', () => {
let wrapper = setup({ component: columnWithoutChildren });
expect(wrapper.find(DeleteComponentButton)).toHaveLength(0);
expect(wrapper.find(DeleteComponentButton)).not.toExist();
// we cannot set props on the Row because of the WithDragDropContext wrapper
wrapper = setup({ component: columnWithoutChildren, editMode: true });
expect(wrapper.find(DeleteComponentButton)).toHaveLength(1);
expect(wrapper.find(DeleteComponentButton)).toExist();
});
it('should render a BackgroundStyleDropdown when focused', () => {
let wrapper = setup({ component: columnWithoutChildren });
expect(wrapper.find(BackgroundStyleDropdown)).toHaveLength(0);
expect(wrapper.find(BackgroundStyleDropdown)).not.toExist();
// we cannot set props on the Row because of the WithDragDropContext wrapper
wrapper = setup({ component: columnWithoutChildren, editMode: true });
@@ -120,7 +120,7 @@ describe('Column', () => {
.at(1) // first one is delete button
.simulate('click');
expect(wrapper.find(BackgroundStyleDropdown)).toHaveLength(1);
expect(wrapper.find(BackgroundStyleDropdown)).toExist();
});
it('should call deleteComponent when deleted', () => {

View File

@@ -58,23 +58,23 @@ describe('Divider', () => {
it('should render a DragDroppable', () => {
const wrapper = setup();
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render a div with class "dashboard-component-divider"', () => {
const wrapper = setup();
expect(wrapper.find('.dashboard-component-divider')).toHaveLength(1);
expect(wrapper.find('.dashboard-component-divider')).toExist();
});
it('should render a HoverMenu with DeleteComponentButton in editMode', () => {
let wrapper = setup();
expect(wrapper.find(HoverMenu)).toHaveLength(0);
expect(wrapper.find(DeleteComponentButton)).toHaveLength(0);
expect(wrapper.find(HoverMenu)).not.toExist();
expect(wrapper.find(DeleteComponentButton)).not.toExist();
// we cannot set props on the Divider because of the WithDragDropContext wrapper
wrapper = setup({ editMode: true });
expect(wrapper.find(HoverMenu)).toHaveLength(1);
expect(wrapper.find(DeleteComponentButton)).toHaveLength(1);
expect(wrapper.find(HoverMenu)).toExist();
expect(wrapper.find(DeleteComponentButton)).toExist();
});
it('should call deleteComponent when deleted', () => {

View File

@@ -66,26 +66,26 @@ describe('Header', () => {
it('should render a DragDroppable', () => {
const wrapper = setup();
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render a WithPopoverMenu', () => {
const wrapper = setup();
expect(wrapper.find(WithPopoverMenu)).toHaveLength(1);
expect(wrapper.find(WithPopoverMenu)).toExist();
});
it('should render a HoverMenu in editMode', () => {
let wrapper = setup();
expect(wrapper.find(HoverMenu)).toHaveLength(0);
expect(wrapper.find(HoverMenu)).not.toExist();
// we cannot set props on the Header because of the WithDragDropContext wrapper
wrapper = setup({ editMode: true });
expect(wrapper.find(HoverMenu)).toHaveLength(1);
expect(wrapper.find(HoverMenu)).toExist();
});
it('should render an EditableTitle with meta.text', () => {
const wrapper = setup();
expect(wrapper.find(EditableTitle)).toHaveLength(1);
expect(wrapper.find(EditableTitle)).toExist();
expect(wrapper.find('input').prop('value')).toBe(props.component.meta.text);
});
@@ -105,7 +105,7 @@ describe('Header', () => {
const wrapper = setup({ editMode: true });
wrapper.find(WithPopoverMenu).simulate('click'); // focus
expect(wrapper.find(DeleteComponentButton)).toHaveLength(1);
expect(wrapper.find(DeleteComponentButton)).toExist();
});
it('should call deleteComponent when deleted', () => {

View File

@@ -69,17 +69,17 @@ describe('Markdown', () => {
it('should render a DragDroppable', () => {
const wrapper = setup();
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render a WithPopoverMenu', () => {
const wrapper = setup();
expect(wrapper.find(WithPopoverMenu)).toHaveLength(1);
expect(wrapper.find(WithPopoverMenu)).toExist();
});
it('should render a ResizableContainer', () => {
const wrapper = setup();
expect(wrapper.find(ResizableContainer)).toHaveLength(1);
expect(wrapper.find(ResizableContainer)).toExist();
});
it('should only have an adjustableWidth if its parent is a Row', () => {
@@ -105,24 +105,24 @@ describe('Markdown', () => {
it('should render an Markdown when NOT focused', () => {
const wrapper = setup();
expect(wrapper.find(AceEditor)).toHaveLength(0);
expect(wrapper.find(ReactMarkdown)).toHaveLength(1);
expect(wrapper.find(AceEditor)).not.toExist();
expect(wrapper.find(ReactMarkdown)).toExist();
});
it('should render an AceEditor when focused and editMode=true and editorMode=edit', () => {
const wrapper = setup({ editMode: true });
expect(wrapper.find(AceEditor)).toHaveLength(0);
expect(wrapper.find(ReactMarkdown)).toHaveLength(1);
expect(wrapper.find(AceEditor)).not.toExist();
expect(wrapper.find(ReactMarkdown)).toExist();
wrapper.find(WithPopoverMenu).simulate('click'); // focus + edit
expect(wrapper.find(AceEditor)).toHaveLength(1);
expect(wrapper.find(ReactMarkdown)).toHaveLength(0);
expect(wrapper.find(AceEditor)).toExist();
expect(wrapper.find(ReactMarkdown)).not.toExist();
});
it('should render a ReactMarkdown when focused and editMode=true and editorMode=preview', () => {
const wrapper = setup({ editMode: true });
wrapper.find(WithPopoverMenu).simulate('click'); // focus + edit
expect(wrapper.find(AceEditor)).toHaveLength(1);
expect(wrapper.find(ReactMarkdown)).toHaveLength(0);
expect(wrapper.find(AceEditor)).toExist();
expect(wrapper.find(ReactMarkdown)).not.toExist();
// we can't call setState on Markdown bc it's not the root component, so call
// the mode dropdown onchange instead
@@ -130,8 +130,8 @@ describe('Markdown', () => {
dropdown.prop('onChange')('preview');
wrapper.update();
expect(wrapper.find(ReactMarkdown)).toHaveLength(1);
expect(wrapper.find(AceEditor)).toHaveLength(0);
expect(wrapper.find(ReactMarkdown)).toExist();
expect(wrapper.find(AceEditor)).not.toExist();
});
it('should call updateComponents when editMode changes from edit => preview, and there are markdownSource changes', () => {
@@ -158,7 +158,7 @@ describe('Markdown', () => {
const wrapper = setup({ editMode: true });
wrapper.find(WithPopoverMenu).simulate('click'); // focus
expect(wrapper.find(DeleteComponentButton)).toHaveLength(1);
expect(wrapper.find(DeleteComponentButton)).toExist();
});
it('should call deleteComponent when deleted', () => {

View File

@@ -72,36 +72,36 @@ describe('Row', () => {
it('should render a DragDroppable', () => {
// don't count child DragDroppables
const wrapper = setup({ component: rowWithoutChildren });
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render a WithPopoverMenu', () => {
// don't count child DragDroppables
const wrapper = setup({ component: rowWithoutChildren });
expect(wrapper.find(WithPopoverMenu)).toHaveLength(1);
expect(wrapper.find(WithPopoverMenu)).toExist();
});
it('should render a HoverMenu in editMode', () => {
let wrapper = setup({ component: rowWithoutChildren });
expect(wrapper.find(HoverMenu)).toHaveLength(0);
expect(wrapper.find(HoverMenu)).not.toExist();
// we cannot set props on the Row because of the WithDragDropContext wrapper
wrapper = setup({ component: rowWithoutChildren, editMode: true });
expect(wrapper.find(HoverMenu)).toHaveLength(1);
expect(wrapper.find(HoverMenu)).toExist();
});
it('should render a DeleteComponentButton in editMode', () => {
let wrapper = setup({ component: rowWithoutChildren });
expect(wrapper.find(DeleteComponentButton)).toHaveLength(0);
expect(wrapper.find(DeleteComponentButton)).not.toExist();
// we cannot set props on the Row because of the WithDragDropContext wrapper
wrapper = setup({ component: rowWithoutChildren, editMode: true });
expect(wrapper.find(DeleteComponentButton)).toHaveLength(1);
expect(wrapper.find(DeleteComponentButton)).toExist();
});
it('should render a BackgroundStyleDropdown when focused', () => {
let wrapper = setup({ component: rowWithoutChildren });
expect(wrapper.find(BackgroundStyleDropdown)).toHaveLength(0);
expect(wrapper.find(BackgroundStyleDropdown)).not.toExist();
// we cannot set props on the Row because of the WithDragDropContext wrapper
wrapper = setup({ component: rowWithoutChildren, editMode: true });
@@ -110,7 +110,7 @@ describe('Row', () => {
.at(1) // first one is delete button
.simulate('click');
expect(wrapper.find(BackgroundStyleDropdown)).toHaveLength(1);
expect(wrapper.find(BackgroundStyleDropdown)).toExist();
});
it('should call deleteComponent when deleted', () => {

View File

@@ -74,7 +74,7 @@ describe('Tabs', () => {
describe('renderType=RENDER_TAB', () => {
it('should render a DragDroppable', () => {
const wrapper = setup();
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render an EditableTitle with meta.text', () => {
@@ -97,17 +97,17 @@ describe('Tabs', () => {
it('should render a WithPopoverMenu', () => {
const wrapper = setup();
expect(wrapper.find(WithPopoverMenu)).toHaveLength(1);
expect(wrapper.find(WithPopoverMenu)).toExist();
});
it('should render a DeleteComponentModal when focused if its not the only tab', () => {
let wrapper = setup();
wrapper.find(WithPopoverMenu).simulate('click'); // focus
expect(wrapper.find(DeleteComponentModal)).toHaveLength(0);
expect(wrapper.find(DeleteComponentModal)).not.toExist();
wrapper = setup({ editMode: true });
wrapper.find(WithPopoverMenu).simulate('click');
expect(wrapper.find(DeleteComponentModal)).toHaveLength(1);
expect(wrapper.find(DeleteComponentModal)).toExist();
wrapper = setup({
editMode: true,
@@ -117,7 +117,7 @@ describe('Tabs', () => {
},
});
wrapper.find(WithPopoverMenu).simulate('click');
expect(wrapper.find(DeleteComponentModal)).toHaveLength(0);
expect(wrapper.find(DeleteComponentModal)).not.toExist();
});
it('should show modal when clicked delete icon', () => {

View File

@@ -71,12 +71,12 @@ describe('Tabs', () => {
it('should render a DragDroppable', () => {
// test just Tabs with no children DragDroppables
const wrapper = setup({ component: { ...props.component, children: [] } });
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should render BootstrapTabs', () => {
const wrapper = setup();
expect(wrapper.find(BootstrapTabs)).toHaveLength(1);
expect(wrapper.find(BootstrapTabs)).toExist();
});
it('should set animation=true, mountOnEnter=true, and unmounOnExit=false on BootstrapTabs for perf', () => {
@@ -144,18 +144,18 @@ describe('Tabs', () => {
it('should render a HoverMenu in editMode', () => {
let wrapper = setup();
expect(wrapper.find(HoverMenu)).toHaveLength(0);
expect(wrapper.find(HoverMenu)).not.toExist();
wrapper = setup({ editMode: true });
expect(wrapper.find(HoverMenu)).toHaveLength(1);
expect(wrapper.find(HoverMenu)).toExist();
});
it('should render a DeleteComponentButton in editMode', () => {
let wrapper = setup();
expect(wrapper.find(DeleteComponentButton)).toHaveLength(0);
expect(wrapper.find(DeleteComponentButton)).not.toExist();
wrapper = setup({ editMode: true });
expect(wrapper.find(DeleteComponentButton)).toHaveLength(1);
expect(wrapper.find(DeleteComponentButton)).toExist();
});
it('should call deleteComponent when deleted', () => {

View File

@@ -49,7 +49,7 @@ describe('DraggableNewComponent', () => {
it('should render a DragDroppable', () => {
const wrapper = setup();
expect(wrapper.find(DragDroppable)).toHaveLength(1);
expect(wrapper.find(DragDroppable)).toExist();
});
it('should pass component={ type, id } to DragDroppable', () => {
@@ -78,6 +78,6 @@ describe('DraggableNewComponent', () => {
it('should add the passed className', () => {
const wrapper = setup();
const className = `.new-component-placeholder.${props.className}`;
expect(wrapper.find(className)).toHaveLength(1);
expect(wrapper.find(className)).toExist();
});
});

View File

@@ -32,7 +32,7 @@ describe('NewColumn', () => {
it('should render a DraggableNewComponent', () => {
const wrapper = setup();
expect(wrapper.find(DraggableNewComponent)).toHaveLength(1);
expect(wrapper.find(DraggableNewComponent)).toExist();
});
it('should set appropriate type and id', () => {

View File

@@ -32,7 +32,7 @@ describe('NewDivider', () => {
it('should render a DraggableNewComponent', () => {
const wrapper = setup();
expect(wrapper.find(DraggableNewComponent)).toHaveLength(1);
expect(wrapper.find(DraggableNewComponent)).toExist();
});
it('should set appropriate type and id', () => {

View File

@@ -32,7 +32,7 @@ describe('NewHeader', () => {
it('should render a DraggableNewComponent', () => {
const wrapper = setup();
expect(wrapper.find(DraggableNewComponent)).toHaveLength(1);
expect(wrapper.find(DraggableNewComponent)).toExist();
});
it('should set appropriate type and id', () => {

View File

@@ -32,7 +32,7 @@ describe('NewRow', () => {
it('should render a DraggableNewComponent', () => {
const wrapper = setup();
expect(wrapper.find(DraggableNewComponent)).toHaveLength(1);
expect(wrapper.find(DraggableNewComponent)).toExist();
});
it('should set appropriate type and id', () => {

View File

@@ -32,7 +32,7 @@ describe('NewTabs', () => {
it('should render a DraggableNewComponent', () => {
const wrapper = setup();
expect(wrapper.find(DraggableNewComponent)).toHaveLength(1);
expect(wrapper.find(DraggableNewComponent)).toExist();
});
it('should set appropriate type and id', () => {

View File

@@ -24,6 +24,6 @@ import HoverMenu from 'src/dashboard/components/menu/HoverMenu';
describe('HoverMenu', () => {
it('should render a div.hover-menu', () => {
const wrapper = shallow(<HoverMenu />);
expect(wrapper.find('.hover-menu')).toHaveLength(1);
expect(wrapper.find('.hover-menu')).toExist();
});
});

View File

@@ -39,12 +39,12 @@ describe('WithPopoverMenu', () => {
it('should render a div with class "with-popover-menu"', () => {
const wrapper = setup();
expect(wrapper.find('.with-popover-menu')).toHaveLength(1);
expect(wrapper.find('.with-popover-menu')).toExist();
});
it('should render the passed children', () => {
const wrapper = setup();
expect(wrapper.find('#child')).toHaveLength(1);
expect(wrapper.find('#child')).toExist();
});
it('should focus on click in editMode', () => {
@@ -61,12 +61,12 @@ describe('WithPopoverMenu', () => {
it('should render menuItems when focused', () => {
const wrapper = setup({ editMode: true });
expect(wrapper.find('#menu1')).toHaveLength(0);
expect(wrapper.find('#menu2')).toHaveLength(0);
expect(wrapper.find('#menu1')).not.toExist();
expect(wrapper.find('#menu2')).not.toExist();
wrapper.simulate('click');
expect(wrapper.find('#menu1')).toHaveLength(1);
expect(wrapper.find('#menu2')).toHaveLength(1);
expect(wrapper.find('#menu1')).toExist();
expect(wrapper.find('#menu2')).toExist();
});
it('should not focus when disableClick=true', () => {

View File

@@ -31,6 +31,6 @@ describe('ResizableContainer', () => {
it('should render a Resizable', () => {
const wrapper = setup();
expect(wrapper.find(Resizable)).toHaveLength(1);
expect(wrapper.find(Resizable)).toExist();
});
});

View File

@@ -25,7 +25,7 @@ import ResizableHandle from 'src/dashboard/components/resizable/ResizableHandle'
describe('ResizableHandle', () => {
it('should render a right resize handle', () => {
const wrapper = shallow(<ResizableHandle.right />);
expect(wrapper.find('.resize-handle.resize-handle--right')).toHaveLength(1);
expect(wrapper.find('.resize-handle.resize-handle--right')).toExist();
});
it('should render a bottom resize handle', () => {