45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { isUploadPath, shouldShowAnalyticsNudge } from '../analyticsConsent';
|
|
|
|
describe('isUploadPath', () => {
|
|
it('detects upload routes', () => {
|
|
expect(isUploadPath('/e/abc/upload')).toBe(true);
|
|
expect(isUploadPath('/e/abc/upload/queue')).toBe(true);
|
|
});
|
|
|
|
it('ignores non-upload routes', () => {
|
|
expect(isUploadPath('/e/abc/gallery')).toBe(false);
|
|
expect(isUploadPath('/settings')).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('shouldShowAnalyticsNudge', () => {
|
|
const baseState = {
|
|
decisionMade: false,
|
|
analyticsConsent: false,
|
|
snoozedUntil: null,
|
|
now: 1000,
|
|
activeSeconds: 60,
|
|
routeCount: 2,
|
|
thresholdSeconds: 60,
|
|
thresholdRoutes: 2,
|
|
isUpload: false,
|
|
};
|
|
|
|
it('returns true when thresholds are met', () => {
|
|
expect(shouldShowAnalyticsNudge(baseState)).toBe(true);
|
|
});
|
|
|
|
it('returns false when consent decision is made', () => {
|
|
expect(shouldShowAnalyticsNudge({ ...baseState, decisionMade: true })).toBe(false);
|
|
});
|
|
|
|
it('returns false when snoozed', () => {
|
|
expect(shouldShowAnalyticsNudge({ ...baseState, snoozedUntil: 2000 })).toBe(false);
|
|
});
|
|
|
|
it('returns false on upload routes', () => {
|
|
expect(shouldShowAnalyticsNudge({ ...baseState, isUpload: true })).toBe(false);
|
|
});
|
|
});
|