1 import { getUnixTimeNowTestOnly, isAtLeastDayAgoTestOnly } from '@proton/shared/lib/desktop/heartbeat';
3 describe('at least one day ago', () => {
4 const now = getUnixTimeNowTestOnly();
7 it('should be true for 5 days ago', () => {
8 expect(isAtLeastDayAgoTestOnly(now - 5 * 24 * hours)).toBe(true);
11 it('should be true for 26 hours ago', () => {
12 expect(isAtLeastDayAgoTestOnly(now - 28 * hours)).toBe(true);
15 // NOTE: intentionaly we omit 23h,24h,25h values to avoid automatic tests
16 // fail twice per year.
18 it('should be false for 22 hours ago', () => {
19 expect(isAtLeastDayAgoTestOnly(now - 22 * hours)).toBe(false);
22 it('should be false for now', () => {
23 expect(isAtLeastDayAgoTestOnly(now)).toBe(false);
26 it('should be false for 1 hours in future', () => {
27 expect(isAtLeastDayAgoTestOnly(now + 1 * hours)).toBe(false);
30 it('should be false for 2 days in future', () => {
31 expect(isAtLeastDayAgoTestOnly(now + 2 * 24 * hours)).toBe(false);