From ebb9fbfc8cc2618b14d8ae107bf7e630eb7573f6 Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Tue, 20 Dec 2022 18:09:31 -0300 Subject: [PATCH] tests: solved add email when the user has an existing email --- packages/accounts-password/password_tests.js | 25 ++++++-------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/packages/accounts-password/password_tests.js b/packages/accounts-password/password_tests.js index ee2ea80ff5..1e318a0031 100644 --- a/packages/accounts-password/password_tests.js +++ b/packages/accounts-password/password_tests.js @@ -9,17 +9,6 @@ const makeTestConnAsync = ); }) -const simplePollAsync = - (testFn) => - new Promise((resolve, reject) => - simplePoll(testFn, - () => { - resolve(true) - }, () => { - reject(false) - })) - - function hashPassword(password) { return { digest: SHA256(password), @@ -1749,20 +1738,20 @@ if (Meteor.isServer) (() => { ]); }); - Tinytest.add("passwords - add email when the user has an existing email " + - "only differing in case", test => { + Tinytest.addAsync("passwords - add email when the user has an existing email " + + "only differing in case", async test => { const origEmail = `${ Random.id() }@turing.com`; - const userId = Accounts.createUser({ + const userId = await Accounts.createUser({ email: origEmail }); const newEmail = `${ Random.id() }@turing.com`; - Accounts.addEmail(userId, newEmail); + await Accounts.addEmail(userId, newEmail); const thirdEmail = origEmail.toUpperCase(); - Accounts.addEmail(userId, thirdEmail, true); - - test.equal(Accounts._findUserByQuery({ id: userId }).emails, [ + await Accounts.addEmail(userId, thirdEmail, true); + const u1 = await Accounts._findUserByQuery({ id: userId }) + test.equal(u1.emails, [ { address: thirdEmail, verified: true }, { address: newEmail, verified: false } ]);