test('Storage/Memory: Delete a game', (assert) => {
  assert.plan(3);
  const game = 'foo';
  const play = {
    foo: 'bar'
  };
  const stats = {
    foo: 'bar'
  };

  const mem = new Memory();
  Promise.all([
    mem.addPlay(game, play),
    mem.setStats(game, stats)
  ])
    .then(() => mem.deleteGame(game))
    .then((res) => {
      assert.ok(res, 'Delete should return truthy value');
      return Promise.all([
        mem.getStats(game),
        mem.getHistory(game)
      ]);
    })
    .then((res) => {
      res.forEach((item) => {
        if (Array.isArray(item)) {
          assert.deepEqual(item, [], 'History should be empty');
        } else {
          assert.deepEqual(item, {}, 'Stats should be empty');
        }
      });
    });
});
test('Storage/Memory: Store/Retrieve Stats', (assert) => {
  assert.plan(4);
  const game = 'foo';
  const stats = {
    foo: 'bar'
  };
  const newStats = {
    bar: 'foo'
  };

  const mem = new Memory();
  mem.setStats(game, stats)
    .then((savedStats) => {
      assert.deepEqual(stats, savedStats, 'Should save stats');
      return mem.getStats(game);
    })
    .then((gottenStats) => {
      assert.deepEqual(stats, gottenStats, 'Should fetch stats');
      return mem.setStats(game, newStats);
    })
    .then((savedNewSavedStats) => {
      assert.deepEqual(newStats, savedNewSavedStats, 'Should fetch new overwritten stats');
    });

  mem.getStats('na')
    .then((noStats) => {
      assert.deepEqual(noStats, {}, 'Should get empty object when there is no stats');
    });
});
test('Storage/File: Store/Retrieve Stats', (assert) => {
  assert.plan(4);
  const game = 'foo';
  const stats = {
    foo: 'bar'
  };
  const newStats = {
    bar: 'foo'
  };

  const db = new File(dbConfig);
  db.setStats(game, stats)
    .then((savedStats) => {
      assert.deepEqual(stats, savedStats, 'Should save stats');
      return db.getStats(game);
    })
    .then((gottenStats) => {
      assert.deepEqual(stats, gottenStats, 'Should fetch stats');
      return db.setStats(game, newStats);
    })
    .then((savedNewSavedStats) => {
      assert.deepEqual(newStats, savedNewSavedStats, 'Should fetch new overwritten stats');
    })
    .catch((err) => {
      assert.fail(err);
    });

  db.getStats('na')
    .then((noStats) => {
      assert.deepEqual(noStats, {}, 'Should get empty object when there is no stats');
    });
});
test('Storage/File: Delete a game', (assert) => {
  assert.plan(3);
  const game = 'foo';
  const play = {
    foo: 'bar'
  };
  const stats = {
    foo: 'bar'
  };

  const db = new File(dbConfig);
  Promise.all([
    db.addPlay(game, play),
    db.setStats(game, stats)
  ])
    .then(() => db.deleteGame(game))
    .then((res) => {
      assert.ok(res, 'Delete should return truthy value');
      return Promise.all([
        db.getStats(game),
        db.getHistory(game)
      ]);
    })
    .then((res) => {
      res.forEach((item) => {
        if (Array.isArray(item)) {
          assert.deepEqual(item, [], 'History should be empty');
        } else {
          assert.deepEqual(item, {}, 'Stats should be empty');
        }
      });
    })
    .catch((err) => {
      assert.fail(err);
    });
});
 .then((gottenStats) => {
   assert.deepEqual(stats, gottenStats, 'Should fetch stats');
   return mem.setStats(game, newStats);
 })