diff --git a/src/tests/users/user_post.spec.ts b/src/tests/users/user_post.spec.ts new file mode 100644 index 0000000..82ac7f4 --- /dev/null +++ b/src/tests/users/user_post.spec.ts @@ -0,0 +1,39 @@ +import axios from 'axios'; +import { config } from '../../config'; + +const base = "http://localhost:" + config.internal_port + +let axios_config = {}; + +beforeAll(async () => { + jest.setTimeout(20000); + const res = await axios.post(base + '/api/auth/login', { username: "demo", password: "demo" }); + let access_token = res.data["access_token"]; + axios_config = { + headers: { "authorization": "Bearer " + access_token }, + validateStatus: undefined + }; +}); + +describe('POST /api/users valid', () => { + it('valid user creation with minimal parameters should return 200', async () => { + const res = await axios.post(base + '/api/users', { + "firstname": "demo_createASD123", + "lastname": "demo_createASD123", + "password": "demo_createASD123", + "email": "demo_createASD123@dev.lauf-fuer-kaya.de" + }, axios_config); + expect(res.status).toEqual(200); + }); + it('valid user creation with all parameters should return 200', async () => { + const res = await axios.post(base + '/api/users', { + "firstname": "demo_createASD123_2", + "middlename": "demo_createASD123_2", + "lastname": "demo_createASD123_2", + "username": "demo_createASD123_2", + "password": "demo_createASD123_2", + "email": "demo_createASD123_2@dev.lauf-fuer-kaya.de" + }, axios_config); + expect(res.status).toEqual(200); + }); +});