From 70c8ee18bcca7715638e5e33cbd63334b364cdb9 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Fri, 10 Jun 2022 16:15:11 +0100 Subject: [PATCH 1/2] chore(jest): add jest tests --- .../BlockchainClient/BlockchainClient.test.ts | 8 ++ .../BlockchainClient.test.ts.snap | 119 ++++++++++++++++++ .../EthereumAdapter/EthereumAdapter.test.ts | 68 ++++++++++ .../EthereumAdapter.test.ts.snap | 13 ++ 4 files changed, 208 insertions(+) create mode 100644 libraries/BlockchainClient/BlockchainClient.test.ts create mode 100644 libraries/BlockchainClient/__snapshots__/BlockchainClient.test.ts.snap create mode 100644 libraries/BlockchainClient/adapters/EthereumAdapter/EthereumAdapter.test.ts create mode 100644 libraries/BlockchainClient/adapters/EthereumAdapter/__snapshots__/EthereumAdapter.test.ts.snap diff --git a/libraries/BlockchainClient/BlockchainClient.test.ts b/libraries/BlockchainClient/BlockchainClient.test.ts new file mode 100644 index 0000000000..1d4cdebdcc --- /dev/null +++ b/libraries/BlockchainClient/BlockchainClient.test.ts @@ -0,0 +1,8 @@ +import * as BlockchainClient from '~/libraries/BlockchainClient/BlockchainClient' + +describe('BlockchainClient.default.getInstance', () => { + test('0', () => { + const result: any = BlockchainClient.default.getInstance() + expect(result).toMatchSnapshot() + }) +}) \ No newline at end of file diff --git a/libraries/BlockchainClient/__snapshots__/BlockchainClient.test.ts.snap b/libraries/BlockchainClient/__snapshots__/BlockchainClient.test.ts.snap new file mode 100644 index 0000000000..6afd1b6846 --- /dev/null +++ b/libraries/BlockchainClient/__snapshots__/BlockchainClient.test.ts.snap @@ -0,0 +1,119 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`BlockchainClient.default.getInstance 0 1`] = ` +BlockchainClient { + "adapter": SolanaAdapter { + "_friendsProgram": null, + "groupsProgram": null, + "solanaManager": SolanaManager { + "accounts": Array [], + "clusterApiUrl": "https://little-cold-butterfly.solana-devnet.quiknode.pro/c858efccfbbe7a6a291948c28193ee8d7f510594/", + "connection": Connection { + "_blockhashInfo": Object { + "lastFetch": 0, + "latestBlockhash": null, + "simulatedSignatures": Array [], + "transactionSignatures": Array [], + }, + "_commitment": "confirmed", + "_confirmTransactionInitialTimeout": undefined, + "_disableBlockhashCaching": false, + "_nextClientSubscriptionId": 0, + "_pollingBlockhash": false, + "_rpcBatchRequest": [Function], + "_rpcClient": ClientBrowser { + "callServer": [Function], + "options": Object { + "generator": [Function], + "notificationIdNull": false, + "replacer": null, + "reviver": null, + "version": 2, + }, + }, + "_rpcEndpoint": "https://little-cold-butterfly.solana-devnet.quiknode.pro/c858efccfbbe7a6a291948c28193ee8d7f510594/", + "_rpcRequest": [Function], + "_rpcWebSocket": Client { + "_events": Object { + "accountNotification": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "close": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "error": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "logsNotification": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "open": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "programNotification": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "rootNotification": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "signatureNotification": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "slotNotification": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + "slotsUpdatesNotification": EE { + "context": [Circular], + "fn": [Function], + "once": false, + }, + }, + "_eventsCount": 10, + "address": "wss://little-cold-butterfly.solana-devnet.quiknode.pro/c858efccfbbe7a6a291948c28193ee8d7f510594/", + "autoconnect": false, + "current_reconnects": 0, + "generate_request_id": [Function], + "max_reconnects": Infinity, + "queue": Object {}, + "ready": false, + "reconnect": true, + "reconnect_interval": 1000, + "rest_options": Object {}, + "rpc_id": 0, + "webSocketFactory": [Function], + }, + "_rpcWebSocketConnected": false, + "_rpcWebSocketGeneration": 0, + "_rpcWebSocketHeartbeat": null, + "_rpcWebSocketIdleTimeout": null, + "_rpcWsEndpoint": "wss://little-cold-butterfly.solana-devnet.quiknode.pro/c858efccfbbe7a6a291948c28193ee8d7f510594/", + "_subscriptionCallbacksByServerSubscriptionId": Object {}, + "_subscriptionDisposeFunctionsByClientSubscriptionId": Object {}, + "_subscriptionsAutoDisposedByRpc": Set {}, + "_subscriptionsByHash": Object {}, + }, + "networkIdentifier": "devnet", + "publicKeys": Object {}, + }, + "usersProgram": null, + }, +} +`; diff --git a/libraries/BlockchainClient/adapters/EthereumAdapter/EthereumAdapter.test.ts b/libraries/BlockchainClient/adapters/EthereumAdapter/EthereumAdapter.test.ts new file mode 100644 index 0000000000..4e097511cc --- /dev/null +++ b/libraries/BlockchainClient/adapters/EthereumAdapter/EthereumAdapter.test.ts @@ -0,0 +1,68 @@ +import * as EthereumAdapter from '~/libraries/BlockchainClient/adapters/EthereumAdapter/EthereumAdapter' +describe('EthereumAdapter.default.acceptFriendRequest', () => { + let inst: any + + beforeEach(() => { + inst = new EthereumAdapter.default() + }) + + test('0', () => { + const param1: any = [ + [false, true, false, false], + [false, true, false, false], + [true, false, true, true], + [false, true, true, false], + ] + const result: any = inst.acceptFriendRequest(param1) + expect(result).toMatchSnapshot() + }) + + test('1', () => { + const param1: any = [ + [false, false, true, false], + [false, false, false, false], + [true, true, true, false], + [true, false, false, false], + ] + const result: any = inst.acceptFriendRequest(param1) + expect(result).toMatchSnapshot() + }) + + test('2', () => { + const param1: any = [ + [false, true, false, true], + [true, false, false, false], + [false, true, false, false], + [false, false, false, true], + ] + const result: any = inst.acceptFriendRequest(param1) + expect(result).toMatchSnapshot() + }) + + test('3', () => { + const param1: any = [ + [true, true, false, false], + [false, true, false, true], + [false, false, false, false], + [true, true, true, false], + ] + const result: any = inst.acceptFriendRequest(param1) + expect(result).toMatchSnapshot() + }) + + test('4', () => { + const param1: any = [ + [true, true, false, false], + [false, true, false, true], + [false, true, false, false], + [true, true, false, true], + ] + const result: any = inst.acceptFriendRequest(param1) + expect(result).toMatchSnapshot() + }) + + test('5', () => { + const result: any = inst.acceptFriendRequest([]) + expect(result).toMatchSnapshot() + }) +}) diff --git a/libraries/BlockchainClient/adapters/EthereumAdapter/__snapshots__/EthereumAdapter.test.ts.snap b/libraries/BlockchainClient/adapters/EthereumAdapter/__snapshots__/EthereumAdapter.test.ts.snap new file mode 100644 index 0000000000..76f8caa8ef --- /dev/null +++ b/libraries/BlockchainClient/adapters/EthereumAdapter/__snapshots__/EthereumAdapter.test.ts.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EthereumAdapter.default.acceptFriendRequest 0 1`] = `Promise {}`; + +exports[`EthereumAdapter.default.acceptFriendRequest 1 1`] = `Promise {}`; + +exports[`EthereumAdapter.default.acceptFriendRequest 2 1`] = `Promise {}`; + +exports[`EthereumAdapter.default.acceptFriendRequest 3 1`] = `Promise {}`; + +exports[`EthereumAdapter.default.acceptFriendRequest 4 1`] = `Promise {}`; + +exports[`EthereumAdapter.default.acceptFriendRequest 5 1`] = `Promise {}`; From 58cfaea95a290a4d3b83dbdee57c5dc02fca0e84 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Fri, 10 Jun 2022 16:20:07 +0100 Subject: [PATCH 2/2] chore(update): minor update --- libraries/BlockchainClient/BlockchainClient.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/BlockchainClient/BlockchainClient.test.ts b/libraries/BlockchainClient/BlockchainClient.test.ts index 1d4cdebdcc..8f5b63dfdc 100644 --- a/libraries/BlockchainClient/BlockchainClient.test.ts +++ b/libraries/BlockchainClient/BlockchainClient.test.ts @@ -1,8 +1,8 @@ import * as BlockchainClient from '~/libraries/BlockchainClient/BlockchainClient' -describe('BlockchainClient.default.getInstance', () => { +describe.skip('BlockchainClient.default.getInstance', () => { //skipped due to the local env test('0', () => { const result: any = BlockchainClient.default.getInstance() expect(result).toMatchSnapshot() }) -}) \ No newline at end of file +})