mirror of
https://github.com/apache/superset.git
synced 2026-04-18 07:35:09 +00:00
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:
committed by
GitHub
parent
671461d0d0
commit
7f70a241f9
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user