文件操作 - RichHistorySettings.test.tsx
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/features/explore/RichHistory/RichHistorySettings.test.tsx
编辑文件内容
import React from 'react'; import { mount } from 'enzyme'; import { RichHistorySettings, RichHistorySettingsProps } from './RichHistorySettings'; import { Select, Switch } from '@grafana/ui'; const setup = (propOverrides?: Partial<RichHistorySettingsProps>) => { const props: RichHistorySettingsProps = { retentionPeriod: 14, starredTabAsFirstTab: true, activeDatasourceOnly: false, onChangeRetentionPeriod: jest.fn(), toggleStarredTabAsFirstTab: jest.fn(), toggleactiveDatasourceOnly: jest.fn(), deleteRichHistory: jest.fn(), }; Object.assign(props, propOverrides); const wrapper = mount(<RichHistorySettings {...props} />); return wrapper; }; describe('RichHistorySettings', () => { it('should render component with correct retention period', () => { const wrapper = setup(); expect(wrapper.find(Select).text()).toEqual('2 weeks'); }); it('should render component with correctly checked starredTabAsFirstTab settings', () => { const wrapper = setup(); expect( wrapper .find(Switch) .at(0) .prop('value') ).toBe(true); }); it('should render component with correctly not checked toggleactiveDatasourceOnly settings', () => { const wrapper = setup(); expect( wrapper .find(Switch) .at(1) .prop('value') ).toBe(false); }); });
修改文件时间
将文件时间修改为当前时间的前一年
删除文件