mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 18:56:32 -05:00
7f665fae4b
Thanks to all HedgeDoc team members for the time discussing, helping with weird Nest issues, providing feedback and suggestions! Co-authored-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Erik Michelson <github@erik.michelson.eu>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
import request from 'supertest';
|
|
|
|
import { TestSetup, TestSetupBuilder } from '../test-setup';
|
|
|
|
describe('Users', () => {
|
|
let testSetup: TestSetup;
|
|
|
|
beforeEach(async () => {
|
|
testSetup = await TestSetupBuilder.create().withUsers().build();
|
|
await testSetup.app.init();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await testSetup.app.close();
|
|
await testSetup.cleanup();
|
|
});
|
|
|
|
test('details for existing users can be retrieved', async () => {
|
|
let response = await request
|
|
.agent(testSetup.app.getHttpServer())
|
|
.get('/api/private/users/profile/testuser1');
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.username).toBe('testuser1');
|
|
|
|
response = await request
|
|
.agent(testSetup.app.getHttpServer())
|
|
.get('/api/private/users/profile/testuser2');
|
|
expect(response.status).toBe(200);
|
|
expect(response.body.username).toBe('testuser2');
|
|
});
|
|
|
|
test('details for non-existing users cannot be retrieved', async () => {
|
|
const response = await request
|
|
.agent(testSetup.app.getHttpServer())
|
|
.get('/api/private/users/profile/i_dont_exist');
|
|
expect(response.status).toBe(404);
|
|
});
|
|
});
|