Updates to test to fix error. No 200 status code given and update for repeat user in DB
This commit is contained in:
@@ -163,7 +163,7 @@ app.post('/register', async (req, res) => {
|
|||||||
await db.none('INSERT INTO users (username, password) VALUES ($1, $2)', [req.body.username, hash]);
|
await db.none('INSERT INTO users (username, password) VALUES ($1, $2)', [req.body.username, hash]);
|
||||||
|
|
||||||
// Redirect user to the login page after successful registration
|
// Redirect user to the login page after successful registration
|
||||||
res.redirect('/home');
|
res.status(200).json({ status: 'success', message: 'Registration successful' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// If an error occurs during registration, respond with status 500 and an error message
|
// If an error occurs during registration, respond with status 500 and an error message
|
||||||
res.status(500).json({ status: 'error', message: 'An error occurred during registration' });
|
res.status(500).json({ status: 'error', message: 'An error occurred during registration' });
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ describe('Server!', () => {
|
|||||||
it('positive: /register', done => {
|
it('positive: /register', done => {
|
||||||
// Define mock user data
|
// Define mock user data
|
||||||
const userData = {
|
const userData = {
|
||||||
username: 'Vishal',
|
username: 'Test User',
|
||||||
password: '123456'
|
password: '123456'
|
||||||
};
|
};
|
||||||
// Make a POST request to /register with mock user data
|
// Make a POST request to /register with mock user data
|
||||||
|
|||||||
Reference in New Issue
Block a user