add sidebar test

This commit is contained in:
Jason Hunter 2021-06-05 21:20:00 -04:00 committed by Blake Blackshear
parent bbb4d10718
commit 2a33c05378

View File

@ -9,8 +9,8 @@ describe('Sidebar', () => {
jest.spyOn(Api, 'useConfig').mockImplementation(() => ({ jest.spyOn(Api, 'useConfig').mockImplementation(() => ({
data: { data: {
cameras: { cameras: {
front: { name: 'front', objects: { track: ['taco', 'cat', 'dog'] } }, front: { name: 'front', objects: { track: ['taco', 'cat', 'dog'] }, record: { enabled: true } },
side: { name: 'side', objects: { track: ['taco', 'cat', 'dog'] } }, side: { name: 'side', objects: { track: ['taco', 'cat', 'dog'] }, record: { enabled: false } },
}, },
}, },
})); }));
@ -30,4 +30,11 @@ describe('Sidebar', () => {
expect(screen.queryByRole('link', { name: 'front' })).toBeInTheDocument(); expect(screen.queryByRole('link', { name: 'front' })).toBeInTheDocument();
expect(screen.queryByRole('link', { name: 'side' })).toBeInTheDocument(); expect(screen.queryByRole('link', { name: 'side' })).toBeInTheDocument();
}); });
test('render cameras if in camera route', async () => {
window.history.replaceState({}, 'Front Recordings', '/recording/front');
render(<Sidebar />);
expect(screen.queryByRole('link', { name: 'front' })).toBeInTheDocument();
expect(screen.queryByRole('link', { name: 'side' })).not.toBeInTheDocument();
});
}); });