parent
9dd9304a71
commit
81d2197a3e
66
src/tests/selfservice/selfservice_register.spec.ts
Normal file
66
src/tests/selfservice/selfservice_register.spec.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import { config } from '../../config';
|
||||||
|
const base = "http://localhost:" + config.internal_port
|
||||||
|
|
||||||
|
let access_token;
|
||||||
|
let axios_config;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
const res = await axios.post(base + '/api/auth/login', { username: "demo", password: "demo" });
|
||||||
|
access_token = res.data["access_token"];
|
||||||
|
axios_config = {
|
||||||
|
headers: { "authorization": "Bearer " + access_token },
|
||||||
|
validateStatus: undefined
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('register invalid citizen', () => {
|
||||||
|
it('registering as citizen without mail should return 406', async () => {
|
||||||
|
const res = await axios.post(base + '/api/runners/register', {
|
||||||
|
"firstname": "string",
|
||||||
|
"middlename": "string",
|
||||||
|
"lastname": "string",
|
||||||
|
}, axios_config);
|
||||||
|
expect(res.status).toEqual(406);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json");
|
||||||
|
});
|
||||||
|
it('registering as citizen with invalid mail should return 400', async () => {
|
||||||
|
const res = await axios.post(base + '/api/runners/register', {
|
||||||
|
"firstname": "string",
|
||||||
|
"middlename": "string",
|
||||||
|
"lastname": "string",
|
||||||
|
"email": "user"
|
||||||
|
}, axios_config);
|
||||||
|
expect(res.status).toEqual(400);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json");
|
||||||
|
});
|
||||||
|
it('registering as citizen without fist name should return 400', async () => {
|
||||||
|
const res = await axios.post(base + '/api/runners/register', {
|
||||||
|
"middlename": "string",
|
||||||
|
"lastname": "string",
|
||||||
|
"email": "user@example.com"
|
||||||
|
}, axios_config);
|
||||||
|
expect(res.status).toEqual(400);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json");
|
||||||
|
});
|
||||||
|
it('registering as citizen without last name should return 400', async () => {
|
||||||
|
const res = await axios.post(base + '/api/runners/register', {
|
||||||
|
"firstname": "string",
|
||||||
|
"middlename": "string",
|
||||||
|
"email": "user@example.com"
|
||||||
|
}, axios_config);
|
||||||
|
expect(res.status).toEqual(400);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json");
|
||||||
|
});
|
||||||
|
it('registering as citizen with invalid mail should return 400', async () => {
|
||||||
|
const res = await axios.post(base + '/api/runners/register', {
|
||||||
|
"firstname": "string",
|
||||||
|
"middlename": "string",
|
||||||
|
"lastname": "string",
|
||||||
|
"phone": "peter",
|
||||||
|
"email": "user@example.com"
|
||||||
|
}, axios_config);
|
||||||
|
expect(res.status).toEqual(400);
|
||||||
|
expect(res.headers['content-type']).toContain("application/json");
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user