in progress: loginUser util for testing
This commit is contained in:
19
server/jest/helpers/loginUser.ts
Normal file
19
server/jest/helpers/loginUser.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import request from 'supertest';
|
||||
|
||||
const agent = request('localhost:8080');
|
||||
|
||||
export default async function loginUser(auth: { token: any }) {
|
||||
const onResponse = (err: any, res: any) => {
|
||||
if (err) throw err;
|
||||
auth.token = res.body.token;
|
||||
}
|
||||
|
||||
agent.post('/auth/login')
|
||||
.send({
|
||||
email: "verifieduser@test.com",
|
||||
password: "verifieduser"
|
||||
})
|
||||
.end(onResponse);
|
||||
|
||||
return auth;
|
||||
}
|
||||
Reference in New Issue
Block a user