Skip to content

Commit

Permalink
Add example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljscript committed May 20, 2024
1 parent cc1e609 commit 4681842
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 72 deletions.
25 changes: 25 additions & 0 deletions apps/wallet-mobile/src/yoroi-wallets/cardano/cip30.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {cip30ExtensionMaker} from './cip30'
import {YoroiWallet} from './types'
import {mocks} from '../mocks'

describe('cip30ExtensionMaker', () => {
it('should support submitTx', async () => {
const mockWallet: YoroiWallet = {
submitTransaction: jest.fn(),
} as any

const cip30 = cip30ExtensionMaker(mockWallet)
const result = await cip30.submitTx(txCbor)
expect(mockWallet.submitTransaction).toHaveBeenCalled()
expect(result).toBe('1a6205dc7a5a0493ef64487ca7033d12ba8f85a7d4a6e62d3c8eaa570d74eb53')
})

it('should support getUtxos', async () => {
const cip30 = cip30ExtensionMaker(mocks.wallet)
const result = await cip30.getUtxos(undefined, undefined)
expect(result).toHaveLength(mocks.wallet.utxos.length)
})
})

const txCbor =
'84a30081825820ab67cc8cfc2904a49066255bbfb3893894e777387ff5389f01e86e3fdd91702900018282583901627e29d0e433daf833d8e80c97c575992cc3abadffd5ac2f64086b5dfd1c740673b5b8840a12cfbbd4e6c5c243bf08bbece4c8b3258194b21a001e848082583901fef19c26a68374e0d32be6b3870e611bf1d34d5e26e95ef2812008d1fd1c740673b5b8840a12cfbbd4e6c5c243bf08bbece4c8b3258194b2821a0761679ba4581c1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1ea150776f726c646d6f62696c65746f6b656e1a005ec5a8581c279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3fa144534e454b1901bc581c8654e8b350e298c80d2451beb5ed80fc9eee9f38ce6b039fb8706bc3a1474c4f42535445521a2d5448dd581ca0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235a145484f534b591a0203a048021a0002af65a0f5f6'
Original file line number Diff line number Diff line change
@@ -1,272 +1,287 @@
[
{
"id": "global.confirmationTransaction",
"defaultMessage": "!!!Confirm transaction",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 32,
"column": 15,
"index": 1709
},
"end": {
"line": 35,
"column": 5,
"index": 1808
}
},
{
"id": "discover.discoverList.discoverTitle",
"defaultMessage": "!!!Discover Cardano",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 31,
"line": 36,
"column": 19,
"index": 1658
"index": 1829
},
"end": {
"line": 34,
"line": 39,
"column": 5,
"index": 1759
"index": 1930
}
},
{
"id": "discover.discoverList.searchDApps",
"defaultMessage": "!!!Search DApps",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 35,
"line": 40,
"column": 17,
"index": 1778
"index": 1949
},
"end": {
"line": 38,
"line": 43,
"column": 5,
"index": 1873
"index": 2044
}
},
{
"id": "discover.discoverList.welcomeToYoroiDAppExplorer",
"defaultMessage": "!!!Welcome to Yoroi DApp Explorer",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 39,
"line": 44,
"column": 32,
"index": 1907
"index": 2078
},
"end": {
"line": 42,
"line": 47,
"column": 5,
"index": 2035
"index": 2206
}
},
{
"id": "discover.discoverList.welcomeToYoroiDAppExplorerDescription",
"defaultMessage": "!!!Discover, inspect, and connect to Cardano decentralized applications (DApps) with ease. Our solution helps to interact with DApps and their smart contracts, seamlessly enhancing your Cardano experience",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 43,
"line": 48,
"column": 43,
"index": 2080
"index": 2251
},
"end": {
"line": 47,
"line": 52,
"column": 5,
"index": 2398
"index": 2569
}
},
{
"id": "global.next",
"defaultMessage": "!!!Next",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 48,
"line": 53,
"column": 10,
"index": 2410
"index": 2581
},
"end": {
"line": 51,
"line": 56,
"column": 5,
"index": 2475
"index": 2646
}
},
{
"id": "discover.discoverList.dAppAvailable",
"defaultMessage": "!!!DApp(s) available",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 52,
"line": 57,
"column": 24,
"index": 2501
"index": 2672
},
"end": {
"line": 55,
"line": 60,
"column": 5,
"index": 2603
"index": 2774
}
},
{
"id": "discover.discoverList.connected",
"defaultMessage": "!!!Connected",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 56,
"line": 61,
"column": 15,
"index": 2620
"index": 2791
},
"end": {
"line": 59,
"line": 64,
"column": 5,
"index": 2710
"index": 2881
}
},
{
"id": "discover.discoverList.recommended",
"defaultMessage": "!!!Recommended",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 60,
"line": 65,
"column": 17,
"index": 2729
"index": 2900
},
"end": {
"line": 63,
"line": 68,
"column": 5,
"index": 2823
"index": 2994
}
},
{
"id": "discover.discoverList.done",
"defaultMessage": "!!!DONE",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 64,
"line": 69,
"column": 10,
"index": 2835
"index": 3006
},
"end": {
"line": 67,
"line": 72,
"column": 5,
"index": 2915
"index": 3086
}
},
{
"id": "discover.discoverList.openDApp",
"defaultMessage": "!!!Open DApp",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 68,
"line": 73,
"column": 14,
"index": 2931
"index": 3102
},
"end": {
"line": 71,
"line": 76,
"column": 5,
"index": 3020
"index": 3191
}
},
{
"id": "discover.discoverList.disconnectWalletFromDApp",
"defaultMessage": "!!!Disconnect wallet from DApp",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 72,
"line": 77,
"column": 30,
"index": 3052
"index": 3223
},
"end": {
"line": 75,
"line": 80,
"column": 5,
"index": 3175
"index": 3346
}
},
{
"id": "discover.discoverList.dAppActions",
"defaultMessage": "!!!DApp actions",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 76,
"line": 81,
"column": 17,
"index": 3194
"index": 3365
},
"end": {
"line": 79,
"line": 84,
"column": 5,
"index": 3289
"index": 3460
}
},
{
"id": "discover.confirmConnectionModal.title",
"defaultMessage": "!!!Confirm connection",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 80,
"line": 85,
"column": 33,
"index": 3324
"index": 3495
},
"end": {
"line": 83,
"line": 88,
"column": 5,
"index": 3429
"index": 3600
}
},
{
"id": "discover.confirmConnectionModal.connectTo",
"defaultMessage": "!!!Connect to",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 84,
"line": 89,
"column": 37,
"index": 3468
"index": 3639
},
"end": {
"line": 87,
"line": 92,
"column": 5,
"index": 3569
"index": 3740
}
},
{
"id": "discover.confirmConnectionModal.connect",
"defaultMessage": "!!!Connect",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 88,
"line": 93,
"column": 35,
"index": 3606
"index": 3777
},
"end": {
"line": 91,
"line": 96,
"column": 5,
"index": 3702
"index": 3873
}
},
{
"id": "discover.confirmConnectionModal.allowThisDAppTo",
"defaultMessage": "!!!Allow this DApp to:",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 92,
"line": 97,
"column": 43,
"index": 3747
"index": 3918
},
"end": {
"line": 95,
"line": 100,
"column": 5,
"index": 3863
"index": 4034
}
},
{
"id": "discover.confirmConnectionModal.permission1",
"defaultMessage": "!!!View addresses, account balance, activity",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 96,
"line": 101,
"column": 39,
"index": 3904
"index": 4075
},
"end": {
"line": 99,
"line": 104,
"column": 5,
"index": 4038
"index": 4209
}
},
{
"id": "discover.confirmConnectionModal.permission2",
"defaultMessage": "!!!Request approval for transactions",
"file": "src/features/Discover/common/useStrings.tsx",
"start": {
"line": 100,
"line": 105,
"column": 39,
"index": 4079
"index": 4250
},
"end": {
"line": 103,
"line": 108,
"column": 5,
"index": 4205
"index": 4376
}
}
]

0 comments on commit 4681842

Please sign in to comment.