Created
June 17, 2022 16:10
-
-
Save ErikGMatos/20192d0ee2815a14e8516c16002c6422 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
oh nice find, i'll check!