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'); const pug = require('pug'); const dateFormat = require('dateformat'); 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) => { for(const item of r) fo.add(item); }); await dbmanager.getRandomSoup(pastTS).then((r) => { fo.addSoup(r); }); const data = fo.forPug(); data.ts = dateFormat(now, 'dddd, mmmm dS, yyyy'); const html = pug.renderFile( '../pug/emailV2.pug', data); const ids = [...fo.getFirstFiveIDs(), fo.soupID()]; console.log(ids); /* await dbmanager.updateTimestamps(currentTS, fo.getFirstFiveIDs()).then((r) => { console.log(r); });*/ t.end(); }); // 1209600000