Skip to content

Commit 1421906

Browse files
test: fix completely broken tests
1 parent 305ac06 commit 1421906

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/advanced-settings/setting-card/SettingCard.test.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { fireEvent, render, waitFor } from '@testing-library/react';
32
import userEvent from '@testing-library/user-event';
43
import { IntlProvider } from '@edx/frontend-platform/i18n';
@@ -22,7 +21,6 @@ jest.mock('react-textarea-autosize', () => jest.fn((props) => (
2221
<textarea
2322
{...props}
2423
onFocus={() => {}}
25-
onBlur={() => {}}
2624
/>
2725
)));
2826

@@ -86,10 +84,10 @@ describe('<SettingCard />', () => {
8684
await waitFor(() => {
8785
expect(inputBox).toHaveValue('3, 2, 1');
8886
});
87+
await user.tab(); // blur off of the input.
8988
await waitFor(() => {
9089
expect(setEdited).toHaveBeenCalled();
9190
expect(handleBlur).toHaveBeenCalled();
9291
});
93-
fireEvent.focusOut(inputBox);
9492
});
9593
});

src/advanced-settings/setting-card/SettingCard.jsx renamed to src/advanced-settings/setting-card/SettingCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const SettingCard = ({
3030
const { deprecated, help, displayName } = settingData;
3131
const initialValue = JSON.stringify(settingData.value, null, 4);
3232
const [isOpen, open, close] = useToggle(false);
33-
const [target, setTarget] = useState(null);
33+
const [target, setTarget] = useState<HTMLButtonElement | null>(null);
3434
const [newValue, setNewValue] = useState(initialValue);
3535

3636
const handleSettingChange = (e) => {
@@ -118,7 +118,7 @@ SettingCard.propTypes = {
118118
deprecated: PropTypes.bool,
119119
help: PropTypes.string,
120120
displayName: PropTypes.string,
121-
value: PropTypes.PropTypes.oneOfType([
121+
value: PropTypes.oneOfType([
122122
PropTypes.string,
123123
PropTypes.bool,
124124
PropTypes.number,

0 commit comments

Comments
 (0)