Skip to content
Snippets Groups Projects
Commit 3639ce2c authored by Bernard Roland (Student Com20)'s avatar Bernard Roland (Student Com20)
Browse files

Added tests for the work endpoint

parent aeae4ee2
No related branches found
No related tags found
No related merge requests found
import supertest from 'supertest';
import { api } from '../api';
import { generateAuthToken } from './auth';
const request = supertest(api);
describe('GET /work', () => {
test('returns information for the unfinished work', async () => {
const resp = await request
.get('/v1/work')
.set('Authorization', `Bearer ${await generateAuthToken('00000000-0000-4000-8000-000000000000')}`);
expect(resp.status).toEqual(200);
expect(resp.body.status).toEqual('success');
expect(resp.body.work).toEqual({
id: '00000000-0000-4000-8000-000000000002',
task: '00000000-0000-4000-8000-000000000005',
user: '00000000-0000-4000-8000-000000000000',
started: Date.parse('2020-10-11T12:00:00'),
finished: null,
});
});
test('returns 404 if no work is unfinished', async () => {
const resp = await request
.get('/v1/work')
.set('Authorization', `Bearer ${await generateAuthToken('00000000-0000-4000-8000-000000000001')}`);
expect(resp.status).toEqual(404);
expect(resp.body.status).toEqual('error');
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment