Skip to content

Commit

Permalink
707: Fixed some lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tombogle committed Feb 27, 2024
1 parent 5ec68c6 commit a5c6983
Show file tree
Hide file tree
Showing 7 changed files with 802 additions and 803 deletions.
294 changes: 147 additions & 147 deletions lib/platform-bible-react/dist/index.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.cjs.map

Large diffs are not rendered by default.

1,270 changes: 636 additions & 634 deletions lib/platform-bible-react/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/platform-bible-react/dist/index.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ describe('ContextMenu', () => {
// Assert the type that schema validation should have already sorted out
// eslint-disable-next-line no-type-assertion/no-type-assertion
const menuData = topMenuCombiner.output as PlatformMenus;
render(<ContextMenu
menuDefinition={menuData.defaultWebViewContextMenu}
commandHandler={() => {}} >
render(
<ContextMenu menuDefinition={menuData.defaultWebViewContextMenu} commandHandler={() => {}}>
click me
</ContextMenu>);
</ContextMenu>,
);

it('renders no menu items before context menu is displayed', () => {
console.log(screen.debug());
expect(screen.queryAllByRole('menuitem').length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ describe('ContextMenu renders', () => {
// Assert the type that schema validation should have already sorted out
// eslint-disable-next-line no-type-assertion/no-type-assertion
const menuData = topMenuCombiner.output as PlatformMenus;
render(<ContextMenu
menuDefinition={menuData.defaultWebViewContextMenu}
commandHandler={() => {}} >
render(
<ContextMenu menuDefinition={menuData.defaultWebViewContextMenu} commandHandler={() => {}}>
click me
</ContextMenu>);
</ContextMenu>,
);

const contextMenuTarget = screen.getByText('click me');
fireEvent.contextMenu(contextMenuTarget);

console.log(screen.debug());

const allMenuItems = screen.queryAllByRole('menuitem');

it('the correct total number of items', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ type SubMenuProps = MenuProps & {
parentMenuItem: MenuItemContainingSubmenu;
};

function getAllGroups(menuDefinition : SingleColumnMenu) {
function getAllGroups(menuDefinition: SingleColumnMenu) {
const groupEntries = Object.entries(menuDefinition.groups);
// Convert array of entries to array of objects with id and group properties
return groupEntries.map(([key, value]) => ({ id: key, group: value }));
};
}

function SubMenu(props: SubMenuProps) {
const [anchorEl, setAnchorEl] = useState<undefined | HTMLElement>(undefined);
Expand Down Expand Up @@ -104,13 +104,14 @@ export default function GroupedMenuItemList(
) {
const { menuDefinition, onClick, commandHandler } = menuProps;

if (includedGroups?.length ?? 0 === 0) {
// We're apparently laying out a single-column menu (presumably a context menu). In this case,
// all groups should be included expect ones that belong to a submenu.
includedGroups = getAllGroups(menuDefinition).filter((g) => !('menuItem' in g.group));
}
const groupsToInclude =
(includedGroups?.length ?? 0) > 0
? includedGroups
: // We're apparently laying out a single-column menu (presumably a context menu). In this case,
// all groups should be included expect ones that belong to a submenu.
getAllGroups(menuDefinition).filter((g) => !('menuItem' in g.group));

const sortedGroups = Object.values(includedGroups).sort(
const sortedGroups = Object.values(groupsToInclude).sort(
(a, b) => (a.group.order || 0) - (b.group.order || 0),
);

Expand Down

0 comments on commit a5c6983

Please sign in to comment.