feat: The X Button in the Top Right Doesn't do anything. (#66)

* fix: tests

* fix: onClose test case
This commit is contained in:
Raymond Zhou
2022-05-04 11:20:23 -07:00
committed by GitHub
parent 0d4688ce75
commit 51f89bdc1e
3 changed files with 26 additions and 6 deletions

View File

@@ -12,7 +12,13 @@ exports[`EditorContainer component render snapshot: initialized. enable save and
>
<IconButton
iconAs="Icon"
onClick={[MockFunction props.onClose]}
onClick={
Object {
"handleCancelClicked": Object {
"onClose": [MockFunction props.onClose],
},
}
}
src={[MockFunction icons.Close]}
/>
</div>
@@ -54,7 +60,13 @@ exports[`EditorContainer component render snapshot: not initialized. disable sav
>
<IconButton
iconAs="Icon"
onClick={[MockFunction props.onClose]}
onClick={
Object {
"handleCancelClicked": Object {
"onClose": [MockFunction props.onClose],
},
}
}
src={[MockFunction icons.Close]}
/>
</div>

View File

@@ -27,7 +27,7 @@ export const EditorContainer = ({
<IconButton
src={Close}
iconAs={Icon}
onClick={onClose}
onClick={handleCancelClicked}
/>
</div>
</ModalDialog.Title>

View File

@@ -1,3 +1,4 @@
import { IconButton } from '@edx/paragon';
import { shallow } from 'enzyme';
import { useDispatch } from 'react-redux';
@@ -36,16 +37,23 @@ describe('EditorContainer component', () => {
beforeEach(() => {
el = shallow(<EditorContainer {...props}>{testContent}</EditorContainer>);
});
test('close behavior is linked to modal onClose and footer onCancel', () => {
test('close behavior is linked to modal onClose', () => {
const expected = hooks.handleCancelClicked({ onClose: props.onClose });
expect(el.children().at(2).props().onCancel).toEqual(expected);
expect(el.find(IconButton)
.props().onClick).toEqual(expected);
});
test('close behavior is linked to footer onCancel', () => {
const expected = hooks.handleCancelClicked({ onClose: props.onClose });
expect(el.children().at(2)
.props().onCancel).toEqual(expected);
});
test('save behavior is linked to footer onSave', () => {
const expected = hooks.handleSaveClicked({
getContent: props.getContent,
dispatch: useDispatch(),
});
expect(el.children().at(2).props().onSave).toEqual(expected);
expect(el.children().at(2)
.props().onSave).toEqual(expected);
});
});
});