2024-04-20 23:41:15 +03:00

26 lines
799 B
JavaScript

const request = require('supertest');
const app = require('../src/app'); // Adjust the path according to your app's entry point location
describe('User Registration and Login', () => {
it('should register a new user', async () => {
const res = await request(app)
.post('/api/users/register')
.send({
email: 'test@example.com',
password: 'Password123'
});
expect(res.statusCode).toEqual(201);
expect(res.body).toHaveProperty('message');
});
it('should log in an existing user', async () => {
const res = await request(app)
.post('/api/users/login')
.send({
email: 'test@example.com',
password: 'Password123'
});
expect(res.statusCode).toEqual(200);
expect(res.body).toHaveProperty('token');
});
});