mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-03-22 12:33:11 -04:00
chore: minor code enhancements
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import React, { createRef } from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import initItemsList from '../../../src/static/js/components/item-list/includes/itemLists/initItemsList';
|
||||
import { useItemList } from '../../../src/static/js/utils/hooks/useItemList';
|
||||
|
||||
// Stub style imports used by the hook so Jest doesn't try to parse SCSS
|
||||
jest.mock('../../../src/static/js/components/item-list/ItemList.scss', () => ({}), { virtual: true });
|
||||
|
||||
@@ -9,9 +12,6 @@ jest.mock('../../../src/static/js/components/item-list/includes/itemLists/initIt
|
||||
default: jest.fn((_lists: any[]) => [{ appendItems: jest.fn() }]),
|
||||
}));
|
||||
|
||||
import initItemsList from '../../../src/static/js/components/item-list/includes/itemLists/initItemsList';
|
||||
import { useItemList } from '../../../src/static/js/utils/hooks/useItemList';
|
||||
|
||||
function HookConsumer(props: any) {
|
||||
const listRef = createRef<HTMLDivElement>();
|
||||
const [items, countedItems, listHandler, setListHandler, onItemsLoad, onItemsCount, addListItems] = useItemList(
|
||||
@@ -32,7 +32,7 @@ function HookConsumer(props: any) {
|
||||
<button data-testid="count-call" onClick={() => onItemsCount(5)} />
|
||||
<button data-testid="add-call" onClick={() => addListItems()} />
|
||||
<button data-testid="set-handler" onClick={() => setListHandler({ foo: 'bar' })} />
|
||||
<div data-testid="has-handler">{listHandler ? 'yes' : 'no'}</div>
|
||||
<div data-testid="has-handler">{listHandler ? 'yes' : 'no'}</div>f
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user