2 diff test

v1.18.x
Barış Soner Uşaklı 7 years ago
parent fc56347c22
commit 4504bbae52

@ -23,7 +23,9 @@ Diffs.exists = function (pid, callback) {
Diffs.get = function (pid, since, callback) {
async.waterfall([
async.apply(db.getListRange.bind(db), 'post:' + pid + ':diffs', 0, -1),
function (next) {
Diffs.list(pid, next);
},
function (timestamps, next) {
// Pass those made after `since`, and create keys
const keys = timestamps.filter(function (timestamp) {

@ -443,6 +443,24 @@ describe('Post\'s', function () {
done();
});
});
it('should return diffs', function (done) {
posts.diffs.get(replyPid, 0, function (err, data) {
assert.ifError(err);
assert(Array.isArray(data));
assert(data[0].pid, replyPid);
assert(data[0].patch);
done();
});
});
it('should load diffs and reconstruct post', function (done) {
posts.diffs.load(replyPid, 0, voterUid, function (err, data) {
assert.ifError(err);
assert.equal(data.content, 'A reply to edit\n');
done();
});
});
});
describe('move', function () {

Loading…
Cancel
Save