need to close DB before deleting and this was a pain.

This commit is contained in:
Jack Case
2025-12-11 16:11:11 +00:00
parent 9dcb237c48
commit fbb11c86cc
2 changed files with 47 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
import { SlopDB } from "../scripts/indexed-db.js"
import { deleteDB } from "../scripts/idb/index.js"
import { openDB, deleteDB } from "../scripts/idb/index.js"
describe("sanity check", () => {
it("works", () => {
@@ -7,15 +7,39 @@ describe("sanity check", () => {
})
})
describe("SlopDB Version 1", () => {
describe("SlopDB", () => {
let db
beforeEach(async () => {
await deleteDB("SlopDB")
})
afterEach(() => {
db.close()
})
it("creates a version 1 indexeddb", async () => {
const slopdb_v1 = new SlopDB(1)
await slopdb_v1.db_opened()
db = slopdb_v1.db
const object_stores = slopdb_v1.db.objectStoreNames
expect(object_stores).toContain("slop")
expect(object_stores).not.toContain("checkcache")
// slopdb_v1.db.close()
})
})
it("creates a version 2 indexeddb", async () => {
const slopdb_v2 = new SlopDB(2)
await slopdb_v2.db_opened()
db = slopdb_v2.db
const object_stores = slopdb_v2.db.objectStoreNames
expect(object_stores).toContain("slop")
expect(object_stores).toContain("checkcache")
// slopdb_v2.db.close()
})
})