🐛 add env to useDb and apply prettier
tinyedge/deploy Deployed by TinyEdge

This commit is contained in:
2026-08-07 13:28:26 +02:00
parent 67727f96ab
commit cbe1b42f6e
54 changed files with 5492 additions and 2406 deletions
+22 -17
View File
@@ -1,33 +1,38 @@
import { describe, expect, it } from 'vitest'
import { readCachedPaymentLink, writeCachedPaymentLink } from './paymentLinkCache'
import { describe, expect, it } from 'vitest';
import {
readCachedPaymentLink,
writeCachedPaymentLink,
} from './paymentLinkCache';
function createMockStorage(): Storage {
const store = new Map<string, string>()
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 },
}
get length() {
return store.size;
},
};
}
describe('payment link cache', () => {
it('returns null when nothing is cached', () => {
expect(readCachedPaymentLink(createMockStorage())).toBeNull()
})
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')
})
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')
})
})
const storage = createMockStorage();
writeCachedPaymentLink(storage, 'https://paypal.me/alice');
writeCachedPaymentLink(storage, 'https://paypal.me/bob');
expect(readCachedPaymentLink(storage)).toBe('https://paypal.me/bob');
});
});