URL objects are being annoying, just store strings and make a URL if portions are needed

This commit is contained in:
Jack Case
2025-12-12 13:46:26 +00:00
parent 7fbfa2a773
commit 55032fe47a
2 changed files with 15 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
import { SlopDB, CheckCache } from "../scripts/indexed-db.js"
import { openDB, deleteDB } from "../scripts/idb/index.js"
const MAX_TIMESTAMP_DIFFERENCE = 3
describe("sanity check", () => {
it("works", () => {
expect(true).toBeTrue()
@@ -58,13 +60,16 @@ describe("SlopDB", () => {
const slop_url = new URL("https://sloppy-slop.com/sloparticle")
await cache.store(slop_url.host)
await cache.store(slop_url.toString())
const store_time = Date.now()
const cached_item = cache.get(slop_url.host)
const cached_item = await cache.get(slop_url.toString())
expect(cached_item.url).toEqual(slop_url)
expect(cached_item.check_timestamp).toBeCloseTo(store_time)
expect(cached_item.url).toEqual(slop_url.toString())
expect(cached_item.check_timestamp).toBeLessThanOrEqual(store_time)
expect(cached_item.check_timestamp).toBeGreaterThan(store_time - MAX_TIMESTAMP_DIFFERENCE)
})
it("updates a cached url's timestamp when it is accessed")
})