diff --git a/tools/push-test.js b/tools/push-test.js index f376a92..612668f 100644 --- a/tools/push-test.js +++ b/tools/push-test.js @@ -37,8 +37,8 @@ const users = require('../users'), push = require('../push'); // events: a local event starting in 10 minutes const soon = new Date(Date.now() + 10 * 60e3), pad = n => String(n).padStart(2, '0'); - const st = `${soon.getUTCFullYear()}-${pad(soon.getUTCMonth() + 1)}-${pad(soon.getUTCDate())}T${pad(soon.getUTCHours())}:${pad(soon.getUTCMinutes())}`; - fs.writeFileSync(path.join(d, 'events.json'), JSON.stringify([{ uid: 'e1', fields: { title: 'Dentist', location: 'Main St', notes: '', allDay: false, start: st, end: st.replace(/T(\d\d)/, (m, h) => 'T' + pad((+h + 1) % 24)), tz: 'UTC', repeat: 'none' }, created: 1, updated: 1 }])); + const utc = d => d.toISOString().slice(0, 16), st = utc(soon), en = utc(new Date(soon.getTime() + 36e5)); // (the end is built from the real time, so an event just before midnight still ends after it starts) + fs.writeFileSync(path.join(d, 'events.json'), JSON.stringify([{ uid: 'e1', fields: { title: 'Dentist', location: 'Main St', notes: '', allDay: false, start: st, end: en, tz: 'UTC', repeat: 'none' }, created: 1, updated: 1 }])); writePush({ tasks: false }); sent.length = 0; await push.tick(new Date(Date.now() - 3 * 36e5), true); ok('an event hours away sends nothing', sent.length === 0, sent);