From bf9652dcfed3667f9d2e8cfd933963935a621a88 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Wed, 3 Mar 2021 16:31:07 +0100 Subject: [PATCH] Added test mail tests ref #4 --- src/tests/test_mail.spec.ts | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/tests/test_mail.spec.ts diff --git a/src/tests/test_mail.spec.ts b/src/tests/test_mail.spec.ts new file mode 100644 index 0000000..ff3dac6 --- /dev/null +++ b/src/tests/test_mail.spec.ts @@ -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" + }) + }); +}); \ No newline at end of file