⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
test
/
core
/
thunk
/
Edit File: thunkTester.ts
import { PayloadAction } from '@reduxjs/toolkit'; import configureMockStore from 'redux-mock-store'; import thunk from 'redux-thunk'; 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: unknown, 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; };
Simpan