diff --git a/libs/react-helpers/src/lib/vega-wallet/provider.test.tsx b/libs/react-helpers/src/lib/vega-wallet/provider.test.tsx
new file mode 100644
index 000000000..6edf40857
--- /dev/null
+++ b/libs/react-helpers/src/lib/vega-wallet/provider.test.tsx
@@ -0,0 +1,104 @@
+import '@testing-library/jest-dom';
+import {
+ act,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@testing-library/react';
+import { RestConnector } from './connectors';
+import { useVegaWallet } from './hooks';
+import { VegaWalletProvider } from './provider';
+import { WALLET_KEY } from './storage-keys';
+
+const restConnector = new RestConnector();
+
+afterAll(() => {
+ localStorage.clear();
+});
+
+const TestComponent = () => {
+ const { connect, disconnect, keypairs, keypair, selectPublicKey } =
+ useVegaWallet();
+ return (
+
+
+
+
{keypair?.pub}
+ {keypairs?.length ? (
+
+ {keypairs.map((kp) => (
+ - selectPublicKey(kp.pub)}>
+ {kp.pub}
+
+ ))}
+
+ ) : null}
+
+ );
+};
+
+const generateJSX = () => (
+
+
+
+);
+
+test('Renders children', async () => {
+ const mockKeypairs = [{ pub: 'public key 1' }, { pub: 'public key 2' }];
+ localStorage.setItem(WALLET_KEY, mockKeypairs[0].pub);
+ jest
+ .spyOn(restConnector, 'connect')
+ // @ts-ignore just using pub to assert state logic
+ .mockImplementation(() => Promise.resolve(mockKeypairs));
+
+ jest
+ .spyOn(restConnector, 'disconnect')
+ .mockImplementation(() => Promise.resolve());
+
+ const { unmount } = render(generateJSX());
+ expect(screen.getByTestId('children')).toBeInTheDocument();
+ await act(async () => {
+ fireEvent.click(screen.getByText('Connect'));
+ });
+ expect(screen.getByTestId('keypair-list').children).toHaveLength(
+ mockKeypairs.length
+ );
+ expect(screen.getByTestId('current-keypair')).toHaveTextContent(
+ mockKeypairs[0].pub
+ );
+
+ // Change current keypair
+ fireEvent.click(screen.getByTestId('keypair-list').children[1]);
+ expect(screen.getByTestId('current-keypair')).toHaveTextContent(
+ mockKeypairs[1].pub
+ );
+
+ // Current keypair should persist
+ unmount();
+ render(generateJSX());
+ await act(async () => {
+ fireEvent.click(screen.getByText('Connect'));
+ });
+ expect(screen.getByTestId('current-keypair')).toHaveTextContent(
+ mockKeypairs[1].pub
+ );
+
+ await act(async () => {
+ fireEvent.click(screen.getByText('Disconnect'));
+ });
+ expect(screen.getByTestId('current-keypair')).toBeEmptyDOMElement();
+ expect(screen.queryByTestId('keypairs-list')).not.toBeInTheDocument();
+});
diff --git a/libs/storage/project.json b/libs/storage/project.json
index 718e67c13..a4edb5567 100644
--- a/libs/storage/project.json
+++ b/libs/storage/project.json
@@ -9,6 +9,7 @@
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/storage",
+ "tsConfig": "libs/storage/tsconfig.lib.json",
"project": "libs/storage/package.json",
"entryFile": "libs/storage/src/index.js",
"rollupConfig": "@nrwl/react/plugins/bundle-rollup",
diff --git a/libs/storage/tsconfig.json b/libs/storage/tsconfig.json
new file mode 100644
index 000000000..4c089585e
--- /dev/null
+++ b/libs/storage/tsconfig.json
@@ -0,0 +1,25 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": true,
+ "esModuleInterop": true,
+ "allowSyntheticDefaultImports": true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "noImplicitOverride": true,
+ "noPropertyAccessFromIndexSignature": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ]
+}
diff --git a/libs/storage/tsconfig.lib.json b/libs/storage/tsconfig.lib.json
new file mode 100644
index 000000000..ad9c3d024
--- /dev/null
+++ b/libs/storage/tsconfig.lib.json
@@ -0,0 +1,26 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "types": ["node"]
+ },
+ "files": [
+ "../../node_modules/@nrwl/react/typings/cssmodule.d.ts",
+ "../../node_modules/@nrwl/react/typings/image.d.ts"
+ ],
+ "exclude": [
+ "**/*.spec.ts",
+ "**/*.test.ts",
+ "**/*.spec.tsx",
+ "**/*.test.tsx",
+ "**/*.spec.js",
+ "**/*.test.js",
+ "**/*.spec.jsx",
+ "**/*.test.jsx",
+ "**/*.stories.ts",
+ "**/*.stories.js",
+ "**/*.stories.jsx",
+ "**/*.stories.tsx"
+ ],
+ "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
+}
diff --git a/libs/storage/tsconfig.spec.json b/libs/storage/tsconfig.spec.json
new file mode 100644
index 000000000..67f149c4c
--- /dev/null
+++ b/libs/storage/tsconfig.spec.json
@@ -0,0 +1,19 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "**/*.test.ts",
+ "**/*.spec.ts",
+ "**/*.test.tsx",
+ "**/*.spec.tsx",
+ "**/*.test.js",
+ "**/*.spec.js",
+ "**/*.test.jsx",
+ "**/*.spec.jsx",
+ "**/*.d.ts"
+ ]
+}