]> zoso.dev Git - libnemo.git/commitdiff
Convert from node to jest test execution.
authorChris Duncan <chris@zoso.dev>
Thu, 5 Dec 2024 18:34:00 +0000 (10:34 -0800)
committerChris Duncan <chris@zoso.dev>
Thu, 5 Dec 2024 18:34:00 +0000 (10:34 -0800)
test/create-wallet.test.mjs

index 4089db507f00e6f489ad1e29f76a1677eefde953..80ff375a54f0d150c889608b475aa258389b622b 100644 (file)
@@ -13,24 +13,24 @@ describe('creating a new wallet', async () => {
                const wallet = await Bip44Wallet.create(NANO_TEST_VECTORS.PASSWORD)\r
                await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
 \r
-               assert.ok('id' in wallet)\r
-               assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.id))\r
-               assert.ok('mnemonic' in wallet)\r
-               assert.ok(/^(?:[a-z]{3,} ){11,23}[a-z]{3,}$/.test(wallet.mnemonic))\r
-               assert.ok('seed' in wallet)\r
-               assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed))\r
+               expect('id' in wallet).toBeTruthy()\r
+               expect(/[A-Fa-f0-9]{32,64}/.test(wallet.id)).toBeTruthy()\r
+               expect('mnemonic' in wallet).toBeTruthy()\r
+               expect(/^(?:[a-z]{3,} ){11,23}[a-z]{3,}$/.test(wallet.mnemonic)).toBeTruthy()\r
+               expect('seed' in wallet).toBeTruthy()\r
+               expect(/[A-Fa-f0-9]{32,64}/.test(wallet.seed)).toBeTruthy()\r
        })\r
 \r
        test('BLAKE2b wallet with random entropy', async () => {\r
                const wallet = await Blake2bWallet.create(NANO_TEST_VECTORS.PASSWORD)\r
                await wallet.unlock(NANO_TEST_VECTORS.PASSWORD)\r
 \r
-               assert.ok('id' in wallet)\r
-               assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.id))\r
-               assert.ok('mnemonic' in wallet)\r
-               assert.ok(/^(?:[a-z]{3,} ){11,23}[a-z]{3,}$/.test(wallet.mnemonic))\r
-               assert.ok('seed' in wallet)\r
-               assert.ok(/[A-Fa-f0-9]{32,64}/.test(wallet.seed))\r
+               expect('id' in wallet).toBeTruthy()\r
+               expect(/[A-Fa-f0-9]{32,64}/.test(wallet.id)).toBeTruthy()\r
+               expect('mnemonic' in wallet).toBeTruthy()\r
+               expect(/^(?:[a-z]{3,} ){11,23}[a-z]{3,}$/.test(wallet.mnemonic)).toBeTruthy()\r
+               expect('seed' in wallet).toBeTruthy()\r
+               expect(/[A-Fa-f0-9]{32,64}/.test(wallet.seed)).toBeTruthy()\r
        })\r
 \r
        test('BIP-44 replace invalid salt with empty string', async () => {\r
@@ -43,22 +43,22 @@ describe('creating a new wallet', async () => {
 \r
        test('fail when using new', async () => {\r
                //@ts-expect-error\r
-               assert.throws(() => new Bip44Wallet())\r
+               expect(() => new Bip44Wallet()).toThrow()\r
                //@ts-expect-error\r
-               assert.throws(() => new Blake2bWallet())\r
+               expect(() => new Blake2bWallet()).toThrow()\r
                //@ts-expect-error\r
-               assert.throws(() => new LedgerWallet())\r
+               expect(() => new LedgerWallet()).toThrow()\r
        })\r
 \r
        test('fail without a password', async () => {\r
                //@ts-expect-error\r
-               await assert.rejects(Bip44Wallet.create())\r
+               expect(async () => await Bip44Wallet.create()).rejects()\r
                //@ts-expect-error\r
-               await assert.rejects(Blake2bWallet.create())\r
+               expect(async () => await Blake2bWallet.create()).rejects()\r
        })\r
 \r
        test.skip('connect to ledger', async () => {\r
                const wallet = await LedgerWallet.create()\r
-               assert.ok(wallet)\r
+               expect(wallet).toBeDefined()\r
        })\r
 })\r