Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
feat: fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
UvgenGen committed Sep 1, 2022
1 parent 46d28e2 commit b20b172
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
17 changes: 8 additions & 9 deletions src/library-authoring/author-library/LibraryAuthoringPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
import {
selectLibraryEdit,
updateLibrary,
} from '../configure-library/data'
} from '../configure-library/data';
import {
BLOCK_FILTER_ORDER,
BLOCK_TYPE_EDIT_DENYLIST,
Expand Down Expand Up @@ -330,29 +330,28 @@ const deriveTypeOptions = (blockTypes, intl) => {
return typeOptions;
};


/**
* LibraryAuthoringPageHeaderBase
* Title component for the LibraryAuthoringPageBase.
*/
const LibraryAuthoringPageHeaderBase = ({intl, library, ...props}) => {
const LibraryAuthoringPageHeaderBase = ({ intl, library, ...props }) => {
const [inputIsActive, setIsActive] = useState(false);
const handleOnBlur = (event) => {
var newTitle = event.target.value;
if (newTitle && newTitle != library.title) {
const newTitle = event.target.value;
if (newTitle && newTitle !== library.title) {
props.updateLibrary({ data: { title: newTitle, libraryId: library.id } });
}
setIsActive(false);
};
const handleClick = (event) => {
const handleClick = () => {
setIsActive(true);
};

return (
<>
<small className="card-subtitle">{intl.formatMessage(messages['library.detail.page.heading'])}</small>
<h1 className="page-header-title">
{inputIsActive
{ inputIsActive
? (
<Input
autoFocus
Expand All @@ -376,8 +375,7 @@ const LibraryAuthoringPageHeaderBase = ({intl, library, ...props}) => {
className="ml-3"
/>
</>
)
}
)}
</h1>
</>
);
Expand All @@ -386,6 +384,7 @@ const LibraryAuthoringPageHeaderBase = ({intl, library, ...props}) => {
LibraryAuthoringPageHeaderBase.propTypes = {
intl: intlShape.isRequired,
library: libraryShape.isRequired,
updateLibrary: PropTypes.func.isRequired,
};

const LibraryAuthoringPageHeader = connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '../../edit-block/data';
import {
updateLibrary,
} from '../../configure-library/data'
} from '../../configure-library/data';

// Reducing function which is used to take an array of blocks and creates an object with keys that are their ids and
// values which are state for interacting with that block.
Expand Down Expand Up @@ -331,14 +331,14 @@ testSuite('<LibraryAuthoringPageContainer />', () => {
const library = libraryFactory();
const block = blockFactory(undefined, { library });
await render(library, genState(library, [block]));
const editButton = screen.getByRole('button', { name: /edit name button/i })

const editButton = screen.getByRole('button', { name: /edit name button/i });
editButton.click();
const input = await screen.getByRole('textbox', { name: /title input/i })
fireEvent.change(input, {target: {value: 'New title'}});
const input = await screen.getByRole('textbox', { name: /title input/i });
fireEvent.change(input, { target: { value: 'New title' } });
fireEvent.focusOut(input);
await waitFor(
() => expect(updateLibrary.fn).toHaveBeenCalledWith({ data: { title: 'New title', libraryId: library.id }}),
() => expect(updateLibrary.fn).toHaveBeenCalledWith({ data: { title: 'New title', libraryId: library.id } }),
);
});
});

0 comments on commit b20b172

Please sign in to comment.