Skip to content

Commit

Permalink
chore(jest): add jest tests (#3569)
Browse files Browse the repository at this point in the history
  • Loading branch information
stavares843 committed Jun 10, 2022
1 parent 1645721 commit 75ffe95
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libraries/BlockchainClient/BlockchainClient.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as BlockchainClient from '~/libraries/BlockchainClient/BlockchainClient'

describe.skip('BlockchainClient.default.getInstance', () => { //skipped due to the local env
test('0', () => {
const result: any = BlockchainClient.default.getInstance()
expect(result).toMatchSnapshot()
})
})
119 changes: 119 additions & 0 deletions libraries/BlockchainClient/__snapshots__/BlockchainClient.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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,
},
}
`;
Original file line number Diff line number Diff line change
@@ -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()
})
})
Original file line number Diff line number Diff line change
@@ -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 {}`;

0 comments on commit 75ffe95

Please sign in to comment.