Added test mail tests

ref #4
This commit is contained in:
Nicolai Ort 2021-03-03 16:31:07 +01:00
parent 38cffc2049
commit bf9652dcfe
1 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,44 @@
import axios from 'axios';
import { config } from '../config';
const base = "http://localhost:" + config.internal_port
const axios_config = {
validateStatus: undefined
};
describe('POST /test without auth', () => {
it('Post without auth should return 401', async () => {
const res = await axios.post(base + '/test', null, axios_config);
expect(res.status).toEqual(401);
});
});
describe('POST /test with auth', () => {
it('Post with auth and no locale should return 200', async () => {
const res = await axios.post(base + '/test?key=' + config.api_key, null, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "en"
})
});
it('Post with auth and locale=en should return 200', async () => {
const res = await axios.post(base + '/test?locale=en&key=' + config.api_key, null, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "en"
})
});
it('Post with auth and locale=de should return 200', async () => {
const res = await axios.post(base + '/test?locale=de&key=' + config.api_key, null, axios_config);
expect(res.status).toEqual(200);
expect(res.data).toEqual({
success: true,
message: "Sent!",
locale: "de"
})
});
});