From 90e0973a7fe55d7711ae0b667b17d7e85f66434c Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Thu, 16 Jun 2022 23:36:13 +0500 Subject: [PATCH] chore: add test for group name validation --- api/src/routes/api/spec/group.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/src/routes/api/spec/group.spec.ts b/api/src/routes/api/spec/group.spec.ts index 5be8538..86196ce 100644 --- a/api/src/routes/api/spec/group.spec.ts +++ b/api/src/routes/api/spec/group.spec.ts @@ -83,6 +83,19 @@ describe('group', () => { expect(res.body).toEqual({}) }) + it('should respond with Bad Request when group name does not match the group name schema', async () => { + const res = await request(app) + .post('/SASjsApi/group') + .auth(adminAccessToken, { type: 'bearer' }) + .send({ ...group, name: 'Wrong Group Name' }) + .expect(400) + + expect(res.text).toEqual( + '"name" must only contain alpha-numeric characters' + ) + expect(res.body).toEqual({}) + }) + it('should respond with Unauthorized if access token is not present', async () => { const res = await request(app).post('/SASjsApi/group').send().expect(401)