user.test.ts 681 B

12345678910111213141516171819202122
  1. import client from './client';
  2. import * as setup from './setup';
  3. describe('GET /api/user', () => {
  4. it('should return current authed user', async () => {
  5. let rsp = await client.get('/api/user');
  6. expect(rsp.data.login).toBe('admin');
  7. });
  8. });
  9. describe('PUT /api/user', () => {
  10. it('should update current authed user', async () => {
  11. const user = await setup.getUser(setup.editor);
  12. user.name = 'Updated via test';
  13. const rsp = await client.callAs(user).put('/api/user', user);
  14. expect(rsp.data.message).toBe('User updated');
  15. const updated = await client.callAs(user).get('/api/user');
  16. expect(updated.data.name).toBe('Updated via test');
  17. });
  18. });