'))
}
})
test('a Discord check is good for 30 days', () => {
assert.equal(MEMBERSHIP_DAYS, 30)
assert.equal(MEMBERSHIP_TTL_MS, 30 * 86_400_000)
const html = renderPage('/mega-radio', { kind: 'unverified', username: 'n', logoutHref: '/x' })
assert.ok(html.includes('A check is good for 30 days.'))
assert.ok(renderPage('/mega-radio', { kind: 'signed-out', loginHref: '/l' }).includes('unlocks the radio for 30 days'))
})
test('member page has players and a repeat icon button, off by default', () => {
const html = renderPage('/mega-radio', { kind: 'member', username: 'n', logoutHref: '/x', discordName: 'Noah', expiresAt: '2026-11-04T00:00:00Z' })
assert.ok(html.includes('data-src="/mega-radio/files/radio/01.mp3"') && html.includes('data-src="/mega-radio/files/radio/02.mp3"') && html.includes('data-src="/mega-radio/files/radio/03.mp3"') && html.includes('data-src="/mega-radio/files/radio/04.mp3"') && html.includes('data-src="/mega-radio/files/radio/05.mp3"'))
assert.ok(!html.includes('/files/radio/06.mp3'))
assert.match(html, /
'), 'plain intro gone for members')
const un = renderPage('/mega-radio', { kind: 'unverified', username: 'n', logoutHref: '/x' }, now)
assert.ok(un.includes('MEGA.dev Discord.') && !un.includes('which now includes you'))
})
test('shortDate: Mon. D in New York time, May without a period, year only when not this year', () => {
const now = new Date('2026-10-28T16:00:00Z')
assert.equal(shortDate('2026-11-27T16:00:00Z', now), 'Nov. 27')
assert.equal(shortDate('2026-05-04T16:00:00Z', now), 'May 4')
assert.equal(shortDate('2026-11-28T03:00:00Z', now), 'Nov. 27', '10pm New York the night before')
assert.equal(shortDate('2027-01-03T16:00:00Z', now), 'Jan. 3, 2027')
})
test('play counts: after the duration, hover title and tap tooltip, on repeat at 3+', async () => {
const { minGapMs, playsTip, onRepeat } = await import('../src/stats.ts')
const html = renderPage('/mega-radio', { kind: 'member', username: 'n', logoutHref: '/x', discordName: 'N', expiresAt: '2026-11-27T00:00:00Z', plays: { 1: { total: 7, mine: 5 }, 2: { total: 1, mine: 0 } } })
assert.match(html, /0:47 · ▶ 7<\/button>/)
assert.ok(html.includes(' · you’ve got it on repeat (5)'))
assert.ok(html.includes('title="1 play by MEGA.dev members"'))
assert.equal(onRepeat(2), '')
assert.equal(playsTip({ total: 0, mine: 0 }), '0 plays by MEGA.dev members')
assert.equal(minGapMs('0:47'), 42_000)
assert.equal(minGapMs('3:20'), 180_000)
assert.equal(minGapMs('0:20'), 30_000)
assert.equal(minGapMs(null), 30_000)
})