diff --git a/server/api/team.test.js b/server/api/team.test.js index 19fb0b0ba..75b0963fd 100644 --- a/server/api/team.test.js +++ b/server/api/team.test.js @@ -34,3 +34,32 @@ describe('#team.users', async () => { expect(body).toMatchSnapshot(); }); }); + +describe('#team.update', async () => { + it('should update team details', async () => { + const { admin } = await seed(); + const res = await server.post('/api/team.update', { + body: { token: admin.getJwtToken(), name: 'New name' }, + }); + const body = await res.json(); + + expect(res.status).toEqual(200); + expect(body.data.name).toEqual('New name'); + }); + + it('should require admin', async () => { + const { user } = await seed(); + const res = await server.post('/api/team.update', { + body: { token: user.getJwtToken(), name: 'New name' }, + }); + const body = await res.json(); + + expect(res.status).toEqual(403); + }); + + it('should require authentication', async () => { + await seed(); + const res = await server.post('/api/team.update'); + expect(res.status).toEqual(401); + }); +}); diff --git a/server/api/user.test.js b/server/api/user.test.js index a7b18e2ab..9324f40ee 100644 --- a/server/api/user.test.js +++ b/server/api/user.test.js @@ -13,13 +13,7 @@ afterAll(server.close); describe('#user.info', async () => { it('should return known user', async () => { - await seed(); - const user = await User.findOne({ - where: { - email: 'user1@example.com', - }, - }); - + const { user } = await seed(); const res = await server.post('/api/user.info', { body: { token: user.getJwtToken() }, }); @@ -41,13 +35,7 @@ describe('#user.info', async () => { describe('#user.update', async () => { it('should update user profile information', async () => { - await seed(); - const user = await User.findOne({ - where: { - email: 'user1@example.com', - }, - }); - + const { user } = await seed(); const res = await server.post('/api/user.update', { body: { token: user.getJwtToken(), name: 'New name' }, });