Merge pull request #16 from purrgrammer/claude/pluggable-storage-engine-F53Fc

Make storage engine pluggable for testing
This commit is contained in:
Alejandro
2025-12-22 13:24:24 +01:00
committed by GitHub
5 changed files with 24 additions and 1 deletions

11
package-lock.json generated
View File

@@ -77,6 +77,7 @@
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
"fake-indexeddb": "^6.2.5",
"globals": "^15.14.0",
"postcss": "^8.4.49",
"prettier": "^3.7.4",
@@ -5966,6 +5967,16 @@
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"license": "MIT"
},
"node_modules/fake-indexeddb": {
"version": "6.2.5",
"resolved": "https://registry.npmjs.org/fake-indexeddb/-/fake-indexeddb-6.2.5.tgz",
"integrity": "sha512-CGnyrvbhPlWYMngksqrSSUT1BAVP49dZocrHuK0SvtR0D5TMs5wP0o3j7jexDJW01KSadjBp1M/71o/KR3nD1w==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">=18"
}
},
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",

View File

@@ -85,6 +85,7 @@
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
"fake-indexeddb": "^6.2.5",
"globals": "^15.14.0",
"postcss": "^8.4.49",
"prettier": "^3.7.4",

View File

@@ -6,12 +6,15 @@ import { describe, it, expect, beforeEach } from "vitest";
import { selectRelaysForFilter } from "./relay-selection";
import { EventStore } from "applesauce-core";
import type { NostrEvent } from "nostr-tools";
import relayListCache from "./relay-list-cache";
describe("selectRelaysForFilter", () => {
let eventStore: EventStore;
beforeEach(() => {
beforeEach(async () => {
eventStore = new EventStore();
// Clear the relay list cache to ensure test isolation
await relayListCache.clear();
});
describe("fallback behavior", () => {

7
src/test/setup.ts Normal file
View File

@@ -0,0 +1,7 @@
/**
* Vitest setup file
*
* Polyfills IndexedDB for Node.js test environment.
* This allows Dexie to work in tests without a browser.
*/
import "fake-indexeddb/auto";

View File

@@ -5,6 +5,7 @@ export default defineConfig({
test: {
globals: true,
environment: "node",
setupFiles: ["./src/test/setup.ts"],
},
resolve: {
alias: {