Skip to content

Instantly share code, notes, and snippets.

@ErikGMatos
Created June 17, 2022 16:10
Show Gist options
  • Save ErikGMatos/20192d0ee2815a14e8516c16002c6422 to your computer and use it in GitHub Desktop.
Save ErikGMatos/20192d0ee2815a14e8516c16002c6422 to your computer and use it in GitHub Desktop.
import React from 'react';
import { render, waitFor, screen, act } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import StackedBar from '~/pages/NewReports/Cards/StackedBar';
import { dashData } from './dashData';
let listener = null;
window.ResizeObserver = class ResizeObserver {
constructor(ls) {
listener = ls;
}
observe() {
return this;
}
disconnect() {
return this;
}
};
describe('Pages', () => {
describe('StackedBar', () => {
const initialValues = dashData;
const mountComponent = props => {
render(<StackedBar {...props} />);
act(() => {
listener([
{
contentRect: {
width: 800,
height: 400,
},
},
]);
});
};
it('should render the component StackBar, be able to do the hover in the graph and show up the tooltip', async () => {
const props = { ...initialValues };
mountComponent(props);
await waitFor(() => {
expect(
screen.getByTestId('label-stacked-bar-sold')
).toBeInTheDocument();
});
userEvent.hover(screen.getAllByTestId(/stacked-bar-rect/)[0]);
await waitFor(() => {
expect(screen.getByTestId('tooltip-stacked-bar')).toBeInTheDocument();
});
});
});
});
@zaeemadamjee
Copy link

oh nice find, i'll check!

@ErikGMatos
Copy link
Author

oh nice find, i'll check!
🚀

@conradoramalho
Copy link

@ErikGMatos this worked on macOS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment