Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
f5916260
Unverified
Commit
f5916260
authored
Nov 20, 2020
by
Giordano Ricci
Committed by
GitHub
Nov 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Allow reducerTester to work with every data type & payload-less actions (#29241)
parent
6838af5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
public/test/core/redux/reducerTester.ts
+7
-6
No files found.
public/test/core/redux/reducerTester.ts
View file @
f5916260
import
{
Reducer
}
from
'redux'
;
import
{
Reducer
}
from
'redux'
;
import
{
PayloadAction
}
from
'@reduxjs/toolkit'
;
import
{
PayloadAction
,
Action
}
from
'@reduxjs/toolkit'
;
import
{
cloneDeep
}
from
'lodash'
;
export
interface
Given
<
State
>
{
export
interface
Given
<
State
>
{
givenReducer
:
(
givenReducer
:
(
reducer
:
Reducer
<
State
,
PayloadAction
<
any
>>
,
reducer
:
Reducer
<
State
,
PayloadAction
<
any
>
|
Action
<
any
>
>
,
state
:
State
,
state
:
State
,
showDebugOutput
?:
boolean
,
showDebugOutput
?:
boolean
,
disableDeepFreeze
?:
boolean
disableDeepFreeze
?:
boolean
...
@@ -11,7 +12,7 @@ export interface Given<State> {
...
@@ -11,7 +12,7 @@ export interface Given<State> {
}
}
export
interface
When
<
State
>
{
export
interface
When
<
State
>
{
whenActionIsDispatched
:
(
action
:
PayloadAction
<
any
>
)
=>
Then
<
State
>
;
whenActionIsDispatched
:
(
action
:
PayloadAction
<
any
>
|
Action
<
any
>
)
=>
Then
<
State
>
;
}
}
export
interface
Then
<
State
>
{
export
interface
Then
<
State
>
{
...
@@ -66,9 +67,9 @@ export const reducerTester = <State>(): Given<State> => {
...
@@ -66,9 +67,9 @@ export const reducerTester = <State>(): Given<State> => {
disableDeepFreeze
=
false
disableDeepFreeze
=
false
):
When
<
State
>
=>
{
):
When
<
State
>
=>
{
reducerUnderTest
=
reducer
;
reducerUnderTest
=
reducer
;
initialState
=
{
...
state
}
;
initialState
=
cloneDeep
(
state
)
;
if
(
!
disableDeepFreeze
)
{
if
(
!
disableDeepFreeze
&&
(
typeof
state
===
'object'
||
typeof
state
===
'function'
)
)
{
initialState
=
deepFreeze
(
initialState
);
deepFreeze
(
initialState
);
}
}
showDebugOutput
=
debug
;
showDebugOutput
=
debug
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment