.then((res) => { assert.ok(res, 'Delete should return truthy value'); return Promise.all([ mem.getStats(game), mem.getHistory(game) ]); })
test('Storage/Memory: Store/Retrieve History', (assert) => { assert.plan(5); const game = 'foo'; const play = { foo: 'bar' }; const mem = new Memory(); mem.addPlay(game, play) .then((res) => { assert.ok(res, 'Should save play'); return mem.getHistory(game); }) .then((gottenHistory) => { assert.deepEqual([play], gottenHistory, 'Should fetch history'); return mem.addPlay(game, play); }) .then((res) => { assert.ok(res, 'Should save play'); return mem.getHistory(game); }) .then((gottenHistory) => { assert.deepEqual([play, play], gottenHistory, 'Should fetch new history'); }); mem.getHistory('na') .then((noHistory) => { assert.deepEqual(noHistory, [], 'Should get empty array when there is no history'); }); });
}, function when(err) { if (err) throw err; var next = this; wiki.getHistory(name, null, function(err, commits) { if (err) throw err; wiki.getPage(name, commits.ids[1], next); }); }, function then(err, page) {
}, function when(err) { if (err) throw err; var next = this; wiki.getHistory(name, null, function(err, commits) { wiki.diff( {filename: name, rev: commits.ids[1]}, {filename: name, rev: commits.ids[0]}, next); }); }, function then(err, diff) {
wiki.writePage(name, content, user, function(err) { if (err) throw err; wiki.getHistory(name, null, function(err, commits) { wiki.rollback(name, commits.ids[1], function(err) { wiki.getPage(name, function(err, actual) { assert.equal('hello', actual.content); done(); }); }); }); });
async function reset() { const history = await getHistory() await Promise.all( Array.from(history).map(([filePath, value]) => { if (typeof value === `string`) { return fs.writeFile(path.resolve(filePath), value, `utf8`) } return fs.remove(path.resolve(filePath)) }) ) await fs.remove(__HISTORY_FILE__) }
test('Storage/File: Store/Retrieve History', (assert) => { assert.plan(5); const game = 'foo'; const play = { foo: 'bar' }; const db = new File(dbConfig); db.addPlay(game, play) .then((res) => { assert.ok(res, 'Should save play'); return db.getHistory(game); }) .then((gottenHistory) => { assert.deepEqual([play], gottenHistory, 'Should fetch history'); return db.addPlay(game, play); }) .then((res) => { assert.ok(res, 'Should save play'); return db.getHistory(game); }) .then((gottenHistory) => { assert.deepEqual([play, play], gottenHistory, 'Should fetch new history'); }) .catch((err) => { assert.fail(err); }); db.getHistory('na') .then((noHistory) => { assert.deepEqual(noHistory, [], 'Should get empty array when there is no history'); }) .catch((err) => { assert.fail(err); }); });
.get(function (req, res) { historyHandler.getHistory(res); });
.then((res) => { assert.ok(res, 'Should save play'); return mem.getHistory(game); })