github.com/thanos-io/thanos@v0.32.5/pkg/ui/react-app/src/pages/graph/PanelList.test.tsx (about) 1 import * as React from 'react'; 2 import { shallow } from 'enzyme'; 3 import PanelList, { PanelListContent } from './PanelList'; 4 import Checkbox from '../../components/Checkbox'; 5 import { Button } from 'reactstrap'; 6 import Panel from './Panel'; 7 8 describe('PanelList', () => { 9 it('renders configuration checkboxes', () => { 10 [ 11 { id: 'use-local-time-checkbox', label: 'Use local time', default: false }, 12 { id: 'query-history-checkbox', label: 'Enable query history', default: false }, 13 { id: 'store-filtering-checkbox', label: 'Enable Store Filtering', default: false }, 14 { id: 'autocomplete-checkbox', label: 'Enable autocomplete', default: true }, 15 { id: 'highlighting-checkbox', label: 'Enable highlighting', default: true }, 16 { id: 'linter-checkbox', label: 'Enable linter', default: true }, 17 ].forEach((cb, idx) => { 18 const panelList = shallow(<PanelList />); 19 const checkbox = panelList.find(Checkbox).at(idx); 20 expect(checkbox.prop('id')).toEqual(cb.id); 21 expect(checkbox.prop('defaultChecked')).toBe(cb.default); 22 expect(checkbox.children().text()).toBe(cb.label); 23 }); 24 }); 25 26 it('renders panels', () => { 27 const panelList = shallow(<PanelListContent {...({ panels: [{ id: 'foo' }] } as any)} />); 28 const panels = panelList.find(Panel); 29 expect(panels.length).toBeGreaterThan(0); 30 }); 31 32 it('renders a button to add a panel', () => { 33 const panelList = shallow(<PanelListContent {...({ panels: [] } as any)} />); 34 const btn = panelList.find(Button); 35 expect(btn.prop('color')).toEqual('primary'); 36 expect(btn.children().text()).toEqual('Add Panel'); 37 }); 38 });