The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { isNativeApp } from '../native/platform';
import { donationsShown, isDonationLink, noticeAsksForDonation, withoutDonationsInApp } from './donations';
vi.mock('../native/platform', () => ({ isNativeApp: vi.fn() }));
const links = [{ href: 'https://ko-fi.com/mauriceboe' }, { href: 'https://discord.gg/x' }];
beforeEach(() => {
vi.mocked(isNativeApp).mockReturnValue(false);
});
describe('isDonationLink', () => {
it('knows the donation pages, their subdomains too', () => {
expect(isDonationLink('https://ko-fi.com/mauriceboe')).toBe(true);
expect(isDonationLink('https://www.BuyMeACoffee.com/mauriceboe')).toBe(true);
expect(isDonationLink('https://www.patreon.com/cw/mauriceboe')).toBe(true);
});
it('is false for anything else, a missing href or one that is no URL', () => {
expect(isDonationLink('https://github.com/liketrek/TREK')).toBe(false);
expect(isDonationLink('https://notko-fi.com/x')).toBe(false);
expect(isDonationLink(undefined)).toBe(false);
expect(isDonationLink('not a url')).toBe(false);
});
});
describe('in a browser', () => {
it('keeps every link and every notice', () => {
expect(donationsShown()).toBe(true);
expect(withoutDonationsInApp(links)).toEqual(links);
});
});
describe('in the native app', () => {
it('drops the donation links', () => {
vi.mocked(isNativeApp).mockReturnValue(true);
expect(donationsShown()).toBe(false);
expect(withoutDonationsInApp(links)).toEqual([{ href: 'https://discord.gg/x' }]);
});
});
describe('noticeAsksForDonation', () => {
it('looks at all three buttons', () => {
expect(noticeAsksForDonation({ cta: { kind: 'link', href: 'https://ko-fi.com/x' } })).toBe(true);
expect(noticeAsksForDonation({ secondaryCta: { kind: 'link', href: 'https://buymeacoffee.com/x' } })).toBe(true);
expect(noticeAsksForDonation({ tertiaryCta: { kind: 'link', href: 'https://www.patreon.com/x' } })).toBe(true);
expect(noticeAsksForDonation({ cta: { kind: 'nav', href: '/settings' }, secondaryCta: null })).toBe(false);
expect(noticeAsksForDonation({ cta: { kind: 'action' } })).toBe(false);
expect(noticeAsksForDonation({})).toBe(false);
});
});