Skip to content

Commit 1099c0e

Browse files
committed
fix: test changes
1 parent 5ee5270 commit 1099c0e

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

index.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,28 @@ const useContextDevTools = (dispatch: Function) => {
2222
// other options like actionSanitizer, stateSanitizer
2323
});
2424
isInitialized = true;
25-
devTools.current.subscribe((message: any) => {
26-
if (message.payload && (message.payload.type === 'JUMP_TO_STATE' || message.payload.type === 'JUMP_TO_ACTION') && message.state) {
27-
const parsedState = JSON.parse(message.state);
28-
sendDispatch({
29-
type: 'IMPORT_STATE',
30-
state: parsedState,
31-
});
32-
} else if (message.type === 'DISPATCH' && message.payload && message.payload.nextLiftedState) {
33-
message.payload.nextLiftedState.computedStates.forEach((cs: { state: any}, csi: number) => {
34-
const actionToSend = message.payload.nextLiftedState.actionsById[csi];
35-
if (actionToSend.action.type !== '@@INIT') {
36-
sendDispatch(actionToSend.action);
37-
}
38-
});
39-
}
40-
});
41-
window.addEventListener('beforeunload', function (e) {
42-
e.preventDefault();
43-
disconnectDevTools();
44-
});
25+
if (typeof devTools.current.subscribe === 'function') {
26+
devTools.current.subscribe((message: any) => {
27+
if (message.payload && (message.payload.type === 'JUMP_TO_STATE' || message.payload.type === 'JUMP_TO_ACTION') && message.state) {
28+
const parsedState = JSON.parse(message.state);
29+
sendDispatch({
30+
type: 'IMPORT_STATE',
31+
state: parsedState,
32+
});
33+
} else if (message.type === 'DISPATCH' && message.payload && message.payload.nextLiftedState) {
34+
message.payload.nextLiftedState.computedStates.forEach((cs: { state: any}, csi: number) => {
35+
const actionToSend = message.payload.nextLiftedState.actionsById[csi];
36+
if (actionToSend.action.type !== '@@INIT') {
37+
sendDispatch(actionToSend.action);
38+
}
39+
});
40+
}
41+
});
42+
window.addEventListener('beforeunload', function (e) {
43+
e.preventDefault();
44+
disconnectDevTools();
45+
});
46+
}
4547
}
4648

4749
const sendDispatch = (args: any) => {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
},
107107
"jest": {
108108
"roots": [
109-
"<rootDir>/src"
109+
"<rootDir>/"
110110
],
111111
"collectCoverageFrom": [
112112
"src/**/*.{js,jsx,ts,tsx}",
@@ -117,8 +117,8 @@
117117
],
118118
"setupFilesAfterEnv": [],
119119
"testMatch": [
120-
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
121-
"<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"
120+
"<rootDir>/**/__tests__/**/*.{js,jsx,ts,tsx}",
121+
"<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}"
122122
],
123123
"testEnvironment": "jest-environment-jsdom-fourteen",
124124
"transform": {

0 commit comments

Comments
 (0)