feat(server,web): libraries (#3124)

* feat: libraries

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Jonathan Jogenfors
2023-09-20 13:16:33 +02:00
committed by GitHub
parent 816db700e1
commit acdc66413c
143 changed files with 10941 additions and 386 deletions

View File

@@ -110,7 +110,7 @@ describe(`${PersonController.name}`, () => {
.set('Authorization', `Bearer ${accessToken}`);
expect(status).toBe(400);
expect(body).toEqual(errorStub.badRequest);
expect(body).toEqual(errorStub.badRequest());
});
it('should return person information', async () => {
@@ -130,25 +130,34 @@ describe(`${PersonController.name}`, () => {
expect(body).toEqual(errorStub.unauthorized);
});
for (const key of ['name', 'featureFaceAssetId', 'isHidden']) {
for (const { key, type } of [
{ key: 'name', type: 'string' },
{ key: 'featureFaceAssetId', type: 'string' },
{ key: 'isHidden', type: 'boolean value' },
]) {
it(`should not allow null ${key}`, async () => {
const { status, body } = await request(server)
.put(`/person/${visiblePerson.id}`)
.set('Authorization', `Bearer ${accessToken}`)
.send({ [key]: null });
expect(status).toBe(400);
expect(body).toEqual(errorStub.badRequest);
expect(body).toEqual(errorStub.badRequest([`${key} must be a ${type}`]));
});
}
it('should not accept invalid birth dates', async () => {
for (const birthDate of [false, 'false', '123567', 123456]) {
for (const { birthDate, response } of [
{ birthDate: false, response: ['id must be a UUID'] },
{ birthDate: 'false', response: ['birthDate must be a Date instance'] },
{ birthDate: '123567', response: ['id must be a UUID'] },
{ birthDate: 123456, response: ['id must be a UUID'] },
]) {
const { status, body } = await request(server)
.put(`/person/${uuidStub.notFound}`)
.set('Authorization', `Bearer ${accessToken}`)
.send({ birthDate });
expect(status).toBe(400);
expect(body).toEqual(errorStub.badRequest);
expect(body).toEqual(errorStub.badRequest(response));
}
});