]> zoso.dev Git - libnemo.git/commitdiff
Revert accidental change to documentation. Add tests for new getAllNames method.
authorChris Duncan <chris@zoso.dev>
Thu, 10 Oct 2024 23:37:48 +0000 (16:37 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 10 Oct 2024 23:37:48 +0000 (16:37 -0700)
src/lib/rolodex.ts
test/manage-rolodex.mjs

index 2ebb7b970b262e42d37e50f74b87f97d091dc867..8101f339e1027965f06c250897e4479bc7ef4fe5 100644 (file)
@@ -65,7 +65,7 @@ export class Rolodex {
        }
 
        /**
-       * Gets all names  associated with a name from the rolodex.
+       * Gets all Nano addresses associated with a name from the rolodex.
        *
        * @param {string} name - Alias to look up
        * @returns {string[]} List of Nano addresses associated with the name
index 93fde29aeb74bb18f06aa6b731e88c9e75b51c3a..bcaff1a867168f485f7cfe0fb5e3f4d574d179a3 100644 (file)
@@ -9,12 +9,19 @@ import { Rolodex, Tools } from '../dist/main.js'
 import { NANO_TEST_VECTORS } from './TEST_VECTORS.js'
 
 describe('rolodex valid contact management', async () => {
-       it('should create a rolodex and add a contact', async () => {
+       it('should create a rolodex and add two contacts', async () => {
                const rolodex = new Rolodex()
                assert.equal(rolodex.constructor, Rolodex)
                await rolodex.add('JohnDoe', NANO_TEST_VECTORS.ADDRESS_0)
+               await rolodex.add('JaneSmith', NANO_TEST_VECTORS.ADDRESS_1)
+
+               assert.equal(rolodex.getAllNames().length, 2)
+               assert.equal(rolodex.getAllNames()[0], 'JohnDoe')
+               assert.equal(rolodex.getAllNames()[1], 'JaneSmith')
                assert.equal(rolodex.getAddresses('JohnDoe').length, 1)
                assert.equal(rolodex.getAddresses('JohnDoe')[0], NANO_TEST_VECTORS.ADDRESS_0)
+               assert.equal(rolodex.getAddresses('JaneSmith').length, 1)
+               assert.equal(rolodex.getAddresses('JaneSmith')[0], NANO_TEST_VECTORS.ADDRESS_1)
        })
 
        it('should get a name from an address', async () => {