commit ce4cbb591fc46cd91fe042e7cd9875f08eeb6e2a
parent fe0d6872fc72376891972e3573302b34e33fc5b6
Author: Matthew Horan <matt@matthoran.com>
Date: Sun, 27 Sep 2020 22:20:25 -0400
Bump redux-persist
AsyncStorage has been extracted from react-native core and will be
removed in a future release. redux-persist 6.0.0 supports using the
extracted module.
Diffstat:
7 files changed, 48 insertions(+), 21 deletions(-)
diff --git a/__mocks__/@react-native-community/async-storage.js b/__mocks__/@react-native-community/async-storage.js
@@ -0,0 +1 @@
+export default from '@react-native-community/async-storage/jest/async-storage-mock'
diff --git a/__tests__/App.js b/__tests__/App.js
@@ -5,8 +5,6 @@ import App from '../src/usecase/App';
import { render } from '../src/test-utils';
it('renders correctly', () => {
- jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
-
const tree = render(<App />, {
initialState: {
buffers: {
diff --git a/jest.config.js b/jest.config.js
@@ -1,18 +1,11 @@
const { defaults: tsjPreset } = require('ts-jest/presets');
module.exports = {
- preset: "jest-expo",
+ preset: 'jest-expo',
transform: {
- ...tsjPreset.transform,
+ ...tsjPreset.transform
},
- moduleFileExtensions: [
- "ts",
- "tsx",
- "js",
- "jsx",
- "json",
- "node"
- ],
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
globals: {
'ts-jest': {
babelConfig: true,
@@ -20,5 +13,6 @@ module.exports = {
strict: false
}
}
- }
-}
+ },
+ setupFiles: ['./jest.setup.js']
+};
diff --git a/jest.setup.js b/jest.setup.js
@@ -0,0 +1,11 @@
+jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
+
+jest.mock('redux-persist', () => {
+ const real = jest.requireActual('redux-persist');
+ return {
+ ...real,
+ persistReducer: jest
+ .fn()
+ .mockImplementation((config, reducers) => reducers)
+ };
+});
diff --git a/package.json b/package.json
@@ -9,6 +9,7 @@
"lint": "eslint . --ext .ts --ext .tsx"
},
"dependencies": {
+ "@react-native-community/async-storage": "^1.12.0",
"date-fns": "^1.29.0",
"expo": "^39.0.0",
"expo-notifications": "~0.7.2",
@@ -20,7 +21,7 @@
"react-native-parsed-text": "^0.0.22",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
- "redux-persist": "^5.9.1",
+ "redux-persist": "^6.0.0",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
diff --git a/src/store/index.ts b/src/store/index.ts
@@ -2,7 +2,7 @@ import { combineReducers, createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import { persistStore, persistReducer } from 'redux-persist';
-import storage from 'redux-persist/lib/storage';
+import AsyncStorage from '@react-native-community/async-storage';
import buffers, { BufferState } from './buffers';
import lines, { LineState } from './lines';
@@ -61,7 +61,10 @@ export const reducer = combineReducers({
});
export const store = createStore(
- persistReducer({ storage, key: 'state', whitelist: ['connection'] }, reducer),
+ persistReducer(
+ { storage: AsyncStorage, key: 'state', whitelist: ['connection'] },
+ reducer
+ ),
composeWithDevTools(applyMiddleware(thunk))
);
diff --git a/yarn.lock b/yarn.lock
@@ -2035,6 +2035,13 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"
+"@react-native-community/async-storage@^1.12.0":
+ version "1.12.0"
+ resolved "https://registry.yarnpkg.com/@react-native-community/async-storage/-/async-storage-1.12.0.tgz#d2fc65bc08aa1c3e9514bbe9fe7095eab8e8aca3"
+ integrity sha512-y3zVxuVyiOxI8TXrvajmYfDbIt2vFNxzV5MiA28v15DQTxDk6uJH3rpc9my+la7u2Tiwt3PpdU2+59ZgZ4h7wA==
+ dependencies:
+ deep-assign "^3.0.0"
+
"@react-native-community/cli-debugger-ui@^4.9.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-4.9.0.tgz#4177764ba69243c97aa26829d59d9501acb2bd71"
@@ -3726,6 +3733,13 @@ decode-uri-component@^0.2.0:
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
+deep-assign@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/deep-assign/-/deep-assign-3.0.0.tgz#c8e4c4d401cba25550a2f0f486a2e75bc5f219a2"
+ integrity sha512-YX2i9XjJ7h5q/aQ/IM9PEwEnDqETAIYbggmdDB3HLTlSgo1CxPsj6pvhPG68rq6SVE0+p+6Ywsm5fTYNrYtBWw==
+ dependencies:
+ is-obj "^1.0.0"
+
deep-equal@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.3.tgz#cad1c15277ad78a5c01c49c2dee0f54de8a6a7b0"
@@ -5359,6 +5373,11 @@ is-number@^7.0.0:
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
+is-obj@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f"
+ integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8=
+
is-plain-object@^2.0.3, is-plain-object@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
@@ -8243,10 +8262,10 @@ redux-devtools-extension@^2.13.8:
resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.8.tgz#37b982688626e5e4993ff87220c9bbb7cd2d96e1"
integrity sha512-8qlpooP2QqPtZHQZRhx3x3OP5skEV1py/zUdMY28WNAocbafxdG2tRD1MWE7sp8obGMNYuLWanhhQ7EQvT1FBg==
-redux-persist@^5.9.1:
- version "5.10.0"
- resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-5.10.0.tgz#5d8d802c5571e55924efc1c3a9b23575283be62b"
- integrity sha512-sSJAzNq7zka3qVHKce1hbvqf0Vf5DuTVm7dr4GtsqQVOexnrvbV47RWFiPxQ8fscnyiuWyD2O92DOxPl0tGCRg==
+redux-persist@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-6.0.0.tgz#b4d2972f9859597c130d40d4b146fecdab51b3a8"
+ integrity sha512-71LLMbUq2r02ng2We9S215LtPu3fY0KgaGE0k8WRgl6RkqxtGfl7HUozz1Dftwsb0D/5mZ8dwAaPbtnzfvbEwQ==
redux-thunk@^2.2.0:
version "2.3.0"