文件操作 - textPanelMigrationHandler.test.ts
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/plugins/panel/text/textPanelMigrationHandler.test.ts
编辑文件内容
import { textPanelMigrationHandler } from './textPanelMigrationHandler'; import { TextOptions } from './types'; import { FieldConfigSource, PanelModel } from '@grafana/data'; describe('textPanelMigrationHandler', () => { describe('when invoked and previous version was old Angular text panel', () => { it('then should migrate options', () => { const panel: any = { content: '<span>Hello World<span>', mode: 'html', }; const result = textPanelMigrationHandler(panel); expect(result.content).toEqual('<span>Hello World<span>'); expect(result.mode).toEqual('html'); }); }); describe('when invoked and previous version was not old Angular text panel', () => { it('then should just pass options through', () => { const panel: PanelModel<TextOptions> = { id: 1, fieldConfig: ({} as unknown) as FieldConfigSource, options: { content: `# Title For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/) `, mode: 'markdown', }, }; const result = textPanelMigrationHandler(panel); expect(result.content).toEqual(`# Title For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/) `); expect(result.mode).toEqual('markdown'); }); }); describe('when invoked and previous version was using text mode', () => { it('then should switch to markdown', () => { const panel: PanelModel<TextOptions> = { id: 1, fieldConfig: ({} as unknown) as FieldConfigSource, options: { content: `# Title For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/) `, mode: 'text', }, }; const result = textPanelMigrationHandler(panel); expect(result.content).toEqual(`# Title For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/) `); expect(result.mode).toEqual('markdown'); }); }); });
修改文件时间
将文件时间修改为当前时间的前一年
删除文件