47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
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",
|
|
type: "TEST"
|
|
})
|
|
});
|
|
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",
|
|
type: "TEST"
|
|
})
|
|
});
|
|
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",
|
|
type: "TEST"
|
|
})
|
|
});
|
|
}); |