mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-18 00:16:41 +01:00
34 lines
1.2 KiB
React
34 lines
1.2 KiB
React
|
import { h } from 'preact';
|
||
|
import * as Api from '../api';
|
||
|
import * as Context from '../context';
|
||
|
import Sidebar from '../Sidebar';
|
||
|
import { render, screen } from '@testing-library/preact';
|
||
|
|
||
|
describe('Sidebar', () => {
|
||
|
beforeEach(() => {
|
||
|
jest.spyOn(Api, 'useConfig').mockImplementation(() => ({
|
||
|
data: {
|
||
|
cameras: {
|
||
|
front: { name: 'front', objects: { track: ['taco', 'cat', 'dog'] } },
|
||
|
side: { name: 'side', objects: { track: ['taco', 'cat', 'dog'] } },
|
||
|
},
|
||
|
},
|
||
|
}));
|
||
|
|
||
|
jest.spyOn(Context, 'useDrawer').mockImplementation(() => ({ showDrawer: true, setShowDrawer: () => {} }));
|
||
|
});
|
||
|
|
||
|
test('does not render cameras by default', async () => {
|
||
|
render(<Sidebar />);
|
||
|
expect(screen.queryByRole('link', { name: 'front' })).not.toBeInTheDocument();
|
||
|
expect(screen.queryByRole('link', { name: 'side' })).not.toBeInTheDocument();
|
||
|
});
|
||
|
|
||
|
test('render cameras if in camera route', async () => {
|
||
|
window.history.replaceState({}, 'Cameras', '/cameras/front');
|
||
|
render(<Sidebar />);
|
||
|
expect(screen.queryByRole('link', { name: 'front' })).toBeInTheDocument();
|
||
|
expect(screen.queryByRole('link', { name: 'side' })).toBeInTheDocument();
|
||
|
});
|
||
|
});
|