All files / src/components/Header NavSublink.js

83.33% Statements 5/6
80% Branches 4/5
100% Functions 2/2
80% Lines 4/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52          61x                     61x 6x       6x                                                            
import React from 'react';
import { Link as RouterLink, withRouter } from 'react-router-dom';
import MenuItem from '@material-ui/core/MenuItem';
import { withStyles } from '@material-ui/core/styles';
 
const styles = (theme) => ({
  menuitem: {
    padding: theme.spacing(2),
    '&:hover': {
      backgroundColor: theme.palette.secondary.main,
      color: theme.palette.text.secondary,
      fontWeight: '700',
    },
  },
});
 
const NavSublink = ({ classes, header, isExternal = false, location, onMatchPath, route }) => {
  Iif (location.pathname.split('/')[1] === route.split('/')[1]) {
    onMatchPath(route);
  }
 
  return (
    <>
      {isExternal ? (
        <MenuItem
          className={classes.menuitem}
          component='a'
          data-cy='menuItem'
          disableGutters
          disableRipple
          href={route}
        >
          {header}
        </MenuItem>
      ) : (
        <MenuItem
          className={classes.menuitem}
          component={RouterLink}
          data-cy='menuItem'
          disableGutters
          disableRipple
          to={route}
        >
          {header}
        </MenuItem>
      )}
    </>
  );
};
 
export default withRouter(withStyles(styles)(NavSublink));