Skip to content

Commit

Permalink
working on middleware test
Browse files Browse the repository at this point in the history
  • Loading branch information
sethdivyansh committed Jun 7, 2024
1 parent ffd269f commit 9e34b69
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added backend/.DS_Store
Binary file not shown.
23 changes: 23 additions & 0 deletions backend/tests/userModel.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import dotenv from 'dotenv';
import mongoose from 'mongoose';

dotenv.config();

describe('insert user', () => {
beforeAll(async () => {
await mongoose.connect(`${process.env.MONGO_URI}/users`);
});

afterAll(async () => {
await mongoose.connection.close();
});

it('should insert a user into collection', async () => {
const users = mongoose.connection.collection('users');
const mockUser = { name: 'user1234', password: 'pass1' };
await users.insertOne(mockUser);

const insertedUser = await users.findOne({ name: 'user1234' });
expect(insertedUser).toEqual(mockUser);
});
});

0 comments on commit 9e34b69

Please sign in to comment.