Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(jest): add jest tests #3569

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}`;