🎉 init

This commit is contained in:
2026-07-01 15:43:18 +02:00
commit 2f492c55be
64 changed files with 11645 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'vitest'
import { readCachedPaymentLink, writeCachedPaymentLink } from './paymentLinkCache'
function createMockStorage(): Storage {
const store = new Map<string, string>()
return {
getItem: (key: string) => store.get(key) ?? null,
setItem: (key: string, value: string) => void store.set(key, value),
removeItem: (key: string) => void store.delete(key),
clear: () => store.clear(),
key: () => null,
get length() { return store.size },
}
}
describe('payment link cache', () => {
it('returns null when nothing is cached', () => {
expect(readCachedPaymentLink(createMockStorage())).toBeNull()
})
it('round-trips a cached link', () => {
const storage = createMockStorage()
writeCachedPaymentLink(storage, 'https://paypal.me/alice')
expect(readCachedPaymentLink(storage)).toBe('https://paypal.me/alice')
})
it('overwrites a previously cached link', () => {
const storage = createMockStorage()
writeCachedPaymentLink(storage, 'https://paypal.me/alice')
writeCachedPaymentLink(storage, 'https://paypal.me/bob')
expect(readCachedPaymentLink(storage)).toBe('https://paypal.me/bob')
})
})