grafana/tests/api/user.test.ts
Torkel Ödegaard ead1c300d7
API Integration Tests via jest (#10899)
* tests: experiment with api tests

* api tests are getting nice

* api: api testing ready for feedback
2018-02-14 10:26:20 +01:00

23 lines
681 B
TypeScript

import client from './client';
import * as setup from './setup';
describe('GET /api/user', () => {
it('should return current authed user', async () => {
let rsp = await client.get('/api/user');
expect(rsp.data.login).toBe('admin');
});
});
describe('PUT /api/user', () => {
it('should update current authed user', async () => {
const user = await setup.getUser(setup.editor);
user.name = 'Updated via test';
const rsp = await client.callAs(user).put('/api/user', user);
expect(rsp.data.message).toBe('User updated');
const updated = await client.callAs(user).get('/api/user');
expect(updated.data.name).toBe('Updated via test');
});
});