Added ability to append to documents. Added test cases for the same (#963)

* added ability to append to documents. Added test cases for the same

* made changes required for lint test

* updated snapshot for document.test.js to reflect new test cases added

* append should not enforce newline character
This commit is contained in:
arpitsingh94
2019-06-14 12:06:24 +05:30
committed by Tom Moor
parent 18a5cd8765
commit 7dfe8785a2
3 changed files with 62 additions and 2 deletions

View File

@@ -1212,6 +1212,42 @@ describe('#documents.update', async () => {
});
expect(res.status).toEqual(403);
});
it('should append document with text', async () => {
const { user, document } = await seed();
const res = await server.post('/api/documents.update', {
body: {
token: user.getJwtToken(),
id: document.id,
text: 'Additional text',
lastRevision: document.revision,
append: true,
},
});
const body = await res.json();
expect(res.status).toEqual(200);
expect(body.data.text).toBe(document.text + 'Additional text');
});
it('should require text while appending', async () => {
const { user, document } = await seed();
const res = await server.post('/api/documents.update', {
body: {
token: user.getJwtToken(),
id: document.id,
lastRevision: document.revision,
title: 'Updated Title',
append: true,
},
});
const body = await res.json();
expect(res.status).toEqual(400);
expect(body).toMatchSnapshot();
});
});
describe('#documents.archive', async () => {