.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');
    });
});
示例#3
0
 }, 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) {
示例#4
0
 }, 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) {
示例#5
0
 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();
       });
     });
   });
 });
示例#6
0
文件: reset.js 项目: Bartekus/gatsby
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__)
}
示例#7
0
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);
 })