test: post diff deletion tests

This commit is contained in:
gasoved
2021-01-29 08:26:50 +03:00
committed by Julian Lam
parent eb642f40b9
commit 72b050b4a8
5 changed files with 67 additions and 1 deletions

View File

@@ -647,6 +647,29 @@ describe('Post\'s', function () {
done();
});
});
it('should not delete first diff of a post', async function () {
const timestamps = await posts.diffs.list(replyPid);
await assert.rejects(async () => {
await posts.diffs.delete(replyPid, timestamps[0], voterUid);
}, {
message: '[[error:invalid-data]]',
});
});
it('should delete a post diff', async function () {
await socketPosts.edit({ uid: voterUid }, { pid: replyPid, content: 'another edit has been made' });
await socketPosts.edit({ uid: voterUid }, { pid: replyPid, content: 'most recent edit' });
const timestamp = (await posts.diffs.list(replyPid)).pop();
await posts.diffs.delete(replyPid, timestamp, voterUid);
const differentTimestamp = (await posts.diffs.list(replyPid)).pop();
assert.notStrictEqual(timestamp, differentTimestamp);
});
it('should load (oldest) diff and reconstruct post correctly after a diff deletion', async function () {
const data = await posts.diffs.load(replyPid, 0, voterUid);
assert.strictEqual(data.content, 'A reply to edit');
});
});
describe('move', function () {