diff --git a/src/db/dbAccess/user.test.js b/src/db/dbAccess/user.test.js
index 7b72d29..bb3b125 100644
--- a/src/db/dbAccess/user.test.js
+++ b/src/db/dbAccess/user.test.js
@@ -4,20 +4,21 @@ import { deleteUser, registerUser } from '#db/index.js';
import * as assert from 'node:assert';
import { initDb } from '#db/db.js';
import { disconnect } from 'mongoose';
+import { AuthDto, RegisterDto } from '#dto/auth/index.js';
dotenv.config();
await initDb();
async function createTestUser() {
- const username = (Math.random() * 1000000).toString();
- const password = (Math.random() * 1000000).toString();
- const email = (Math.random() * 1000000).toString() + '@example.com';
+ const authData = await AuthDto.create({
+ username: (Math.random() * 1000000).toString(),
+ password: (Math.random() * 1000000).toString(),
+ email: (Math.random() * 1000000).toString() + '@example.com'
+ });
return {
- username,
- password,
- email,
- user: await registerUser(username, password, email)
+ authData,
+ user: await registerUser(await RegisterDto.create(authData))
};
}
@@ -26,9 +27,9 @@ await it('Can create user', async () => {
});
await it('Can delete user', async () => {
- const { password, user } = await createTestUser();
+ const { authData } = await createTestUser();
- const deletePromise = deleteUser(user._id, password);
+ const deletePromise = deleteUser(authData);
await assert.doesNotReject(deletePromise);
});
|