From fda97c8b83ff42ca66bed7f90d686add634b5823 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 10 Oct 2024 16:37:48 -0700 Subject: [PATCH] Revert accidental change to documentation. Add tests for new getAllNames method. --- src/lib/rolodex.ts | 2 +- test/manage-rolodex.mjs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/rolodex.ts b/src/lib/rolodex.ts index 2ebb7b9..8101f33 100644 --- a/src/lib/rolodex.ts +++ b/src/lib/rolodex.ts @@ -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 diff --git a/test/manage-rolodex.mjs b/test/manage-rolodex.mjs index 93fde29..bcaff1a 100644 --- a/test/manage-rolodex.mjs +++ b/test/manage-rolodex.mjs @@ -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 () => { -- 2.34.1