parent
38cffc2049
commit
bf9652dcfe
44
src/tests/test_mail.spec.ts
Normal file
44
src/tests/test_mail.spec.ts
Normal 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"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user