Skip to content

Commit f9eb9b7

Browse files
committed
test(textarea-caret): properly mocked
1 parent a2ee485 commit f9eb9b7

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

__mocks__/textarea-caret.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = () => ({
2+
start: 0,
3+
end: 0,
4+
});

src/Textarea.jsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,8 @@ class ReactTextareaAutocomplete extends React.Component {
294294
return;
295295
}
296296

297-
/*
298-
JSDOM has some issue with getComputedStyles which is called by getCaretCoordinates
299-
so this try - catch is walk-around for Jest
300-
*/
301-
try {
302-
const { top, left } = getCaretCoordinates(textarea, selectionEnd);
303-
this.setState({ top, left });
304-
} catch (err) {
305-
//eslint-disable-next-line
306-
console.warn(
307-
'RTA: failed to get caret coordinates. This is not a browser?',
308-
);
309-
}
297+
const { top, left } = getCaretCoordinates(textarea, selectionEnd);
298+
this.setState({ top, left });
310299

311300
this.setState(
312301
{

0 commit comments

Comments
 (0)