文件操作 - thunkTester.ts
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/test/core/thunk/thunkTester.ts
编辑文件内容
// @ts-ignore import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; import { PayloadAction } from '@reduxjs/toolkit'; const mockStore = configureMockStore([thunk]); export interface ThunkGiven { givenThunk: (thunkFunction: any) => ThunkWhen; } export interface ThunkWhen { whenThunkIsDispatched: (...args: any) => Promise<Array<PayloadAction<any>>>; } export const thunkTester = (initialState: any, debug?: boolean): ThunkGiven => { const store = mockStore(initialState); let thunkUnderTest: any = null; let dispatchedActions: Array<PayloadAction<any>> = []; const givenThunk = (thunkFunction: any): ThunkWhen => { thunkUnderTest = thunkFunction; return instance; }; const whenThunkIsDispatched = async (...args: any): Promise<Array<PayloadAction<any>>> => { await store.dispatch(thunkUnderTest(...args)); dispatchedActions = store.getActions(); if (debug) { console.log('resultingActions:', JSON.stringify(dispatchedActions, null, 2)); } return dispatchedActions; }; const instance = { givenThunk, whenThunkIsDispatched, }; return instance; };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件