mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 01:05:20 +03:00
added scrollIntoView to test
This commit is contained in:
parent
0d60bad752
commit
d3e2bebfab
@ -20,8 +20,8 @@ export default function Event({ eventId, close, scrollIntoView }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Call Events.js scroll when this event has been mounted.
|
// Call Events.js scroll when this event has been mounted.
|
||||||
() => scrollIntoView(eventId);
|
scrollIntoView(eventId);
|
||||||
}, []);
|
}, [scrollIntoView]);
|
||||||
|
|
||||||
const handleClickDelete = () => {
|
const handleClickDelete = () => {
|
||||||
setShowDialog(true);
|
setShowDialog(true);
|
||||||
|
|||||||
@ -16,12 +16,12 @@ describe('Event Route', () => {
|
|||||||
|
|
||||||
test('shows an ActivityIndicator if not yet loaded', async () => {
|
test('shows an ActivityIndicator if not yet loaded', async () => {
|
||||||
useEventMock.mockReturnValueOnce(() => ({ status: 'loading' }));
|
useEventMock.mockReturnValueOnce(() => ({ status: 'loading' }));
|
||||||
render(<Event eventId={mockEvent.id} />);
|
render(<Event eventId={mockEvent.id} scrollIntoView={mockEvent.scrollIntoView} />);
|
||||||
expect(screen.queryByLabelText('Loading…')).toBeInTheDocument();
|
expect(screen.queryByLabelText('Loading…')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('shows cameras', async () => {
|
test('shows cameras', async () => {
|
||||||
render(<Event eventId={mockEvent.id} />);
|
render(<Event eventId={mockEvent.id} scrollIntoView={mockEvent.scrollIntoView} />);
|
||||||
|
|
||||||
expect(screen.queryByLabelText('Loading…')).not.toBeInTheDocument();
|
expect(screen.queryByLabelText('Loading…')).not.toBeInTheDocument();
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ describe('Event Route', () => {
|
|||||||
|
|
||||||
test('does not render a video if there is no clip', async () => {
|
test('does not render a video if there is no clip', async () => {
|
||||||
useEventMock.mockReturnValue({ data: { ...mockEvent, has_clip: false }, status: 'loaded' });
|
useEventMock.mockReturnValue({ data: { ...mockEvent, has_clip: false }, status: 'loaded' });
|
||||||
render(<Event eventId={mockEvent.id} />);
|
render(<Event eventId={mockEvent.id} scrollIntoView={mockEvent.scrollIntoView} />);
|
||||||
|
|
||||||
expect(screen.queryByText('Clip')).not.toBeInTheDocument();
|
expect(screen.queryByText('Clip')).not.toBeInTheDocument();
|
||||||
expect(screen.queryByLabelText('Video Player')).not.toBeInTheDocument();
|
expect(screen.queryByLabelText('Video Player')).not.toBeInTheDocument();
|
||||||
@ -43,7 +43,7 @@ describe('Event Route', () => {
|
|||||||
|
|
||||||
test('shows the thumbnail if no snapshot available', async () => {
|
test('shows the thumbnail if no snapshot available', async () => {
|
||||||
useEventMock.mockReturnValue({ data: { ...mockEvent, has_clip: false, has_snapshot: false }, status: 'loaded' });
|
useEventMock.mockReturnValue({ data: { ...mockEvent, has_clip: false, has_snapshot: false }, status: 'loaded' });
|
||||||
render(<Event eventId={mockEvent.id} />);
|
render(<Event eventId={mockEvent.id} scrollIntoView={mockEvent.scrollIntoView} />);
|
||||||
|
|
||||||
expect(screen.queryByText('Best Image')).not.toBeInTheDocument();
|
expect(screen.queryByText('Best Image')).not.toBeInTheDocument();
|
||||||
expect(screen.queryByText('Thumbnail')).toBeInTheDocument();
|
expect(screen.queryByText('Thumbnail')).toBeInTheDocument();
|
||||||
@ -66,4 +66,5 @@ const mockEvent = {
|
|||||||
top_score: 0.8203125,
|
top_score: 0.8203125,
|
||||||
zones: ['front_patio'],
|
zones: ['front_patio'],
|
||||||
thumbnail: '/9j/4aa...',
|
thumbnail: '/9j/4aa...',
|
||||||
|
scrollIntoView: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user