menuserver/tests/db.js

36 lines
825 B
JavaScript
Raw Normal View History

const tape = require('tape');
const _test = require('tape-promise').default; // <---- notice 'default'
const test = _test(tape); // decorate tape
const dbmanager = require('../server/lib/dbmanager');
const FoodObj = require('../server/lib/FoodObj');
test('DB tests', async function(t) {
const now = new Date();
const currentTS = ~~(now.getTime() / 86400000) * 86400000;
const pastTS = currentTS - (86400000 * 28);
console.log(currentTS);
const fo = new FoodObj(2);
await dbmanager.getRandom(pastTS).then((r) => {
// console.log(r);
for(const item of r)
fo.add(item);
console.log(fo.getFirstFive());
console.log(fo.getFirstFiveIDs());
});
await dbmanager.updateTimestamps(currentTS, fo.getFirstFiveIDs()).then((r) => {
console.log(r);
});
t.end();
});
// 1209600000