Commit fb95af45 authored by Robert Knight's avatar Robert Knight

Add missing types to MarkdownEditor

 - Add missing types in MarkdownEditor implementation

 - Simplify `onEditText` prop to take a single `text` string argument
   instead of an object with a `text` property
parent f9bb654a
...@@ -107,7 +107,8 @@ function AnnotationEditor({ ...@@ -107,7 +107,8 @@ function AnnotationEditor({
); );
const onEditText = useCallback( const onEditText = useCallback(
({ text }) => { /** @param {string} text */
text => {
store.createDraft(draft.annotation, { ...draft, text }); store.createDraft(draft.annotation, { ...draft, text });
}, },
[draft, store] [draft, store]
......
...@@ -98,7 +98,7 @@ describe('AnnotationEditor', () => { ...@@ -98,7 +98,7 @@ describe('AnnotationEditor', () => {
const editor = wrapper.find('MarkdownEditor'); const editor = wrapper.find('MarkdownEditor');
act(() => { act(() => {
editor.props().onEditText({ text: 'updated text' }); editor.props().onEditText('updated text');
}); });
const call = fakeStore.createDraft.getCall(0); const call = fakeStore.createDraft.getCall(0);
......
This diff is collapsed.
...@@ -119,9 +119,7 @@ describe('MarkdownEditor', () => { ...@@ -119,9 +119,7 @@ describe('MarkdownEditor', () => {
button.simulate('click'); button.simulate('click');
assert.calledWith(onEditText, { assert.calledWith(onEditText, 'formatted text');
text: 'formatted text',
});
const [formatFunction, ...args] = effect; const [formatFunction, ...args] = effect;
assert.calledWith( assert.calledWith(
formatFunction, formatFunction,
...@@ -184,9 +182,7 @@ describe('MarkdownEditor', () => { ...@@ -184,9 +182,7 @@ describe('MarkdownEditor', () => {
key: keyEvent.key, key: keyEvent.key,
}); });
assert.calledWith(onEditText, { assert.calledWith(onEditText, 'formatted text');
text: 'formatted text',
});
const [formatFunction, ...args] = effect; const [formatFunction, ...args] = effect;
assert.calledWith( assert.calledWith(
formatFunction, formatFunction,
...@@ -235,9 +231,7 @@ describe('MarkdownEditor', () => { ...@@ -235,9 +231,7 @@ describe('MarkdownEditor', () => {
const input = wrapper.find('textarea').getDOMNode(); const input = wrapper.find('textarea').getDOMNode();
input.value = 'changed'; input.value = 'changed';
wrapper.find('textarea').simulate('input'); wrapper.find('textarea').simulate('input');
assert.calledWith(onEditText, { assert.calledWith(onEditText, 'changed');
text: 'changed',
});
}); });
it('enters preview mode when Preview button is clicked', () => { it('enters preview mode when Preview button is clicked', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment