From d421454871ddd4e79ef832387b008fd7339607f3 Mon Sep 17 00:00:00 2001 From: Nuttawut Kongsuwan Date: Fri, 15 Dec 2023 09:03:50 +0700 Subject: [PATCH] update with @lenkan suggestion --- examples/integration-scripts/challenge.test.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/examples/integration-scripts/challenge.test.ts b/examples/integration-scripts/challenge.test.ts index 869b1aed..ef1a4b31 100644 --- a/examples/integration-scripts/challenge.test.ts +++ b/examples/integration-scripts/challenge.test.ts @@ -92,7 +92,9 @@ test('challenge', async () => { // List Client 1 contacts let contacts1 = await client1.contacts().list(); - let bobContact = findContact(contacts1, 'bob'); + let bobContact = contacts1.find( + (contact: { alias: string }) => contact.alias === 'bob' + ); expect(bobContact.alias).toEqual('bob'); expect(bobContact.challenges).toHaveLength(0); @@ -120,16 +122,8 @@ test('challenge', async () => { // Check Bob's challenge in conctats contacts1 = await client1.contacts().list(); - bobContact = findContact(contacts1, 'bob'); + bobContact = contacts1.find( + (contact: { alias: string }) => contact.alias === 'bob' + ); expect(bobContact.challenges[0].authenticated).toEqual(true); }, 30000); - -function findContact(contactsList: any, name: any) { - let contact: any; - for (const index in contactsList) { - if (contactsList[index].alias == name) { - contact = contactsList[index]; - } - } - return contact; -}