@forthtilliath/expo-test-kit 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,16 +22,21 @@ Or, from within this monorepo, as a workspace dependency:
22
22
 
23
23
  ## Usage
24
24
 
25
- Each function is its own module — import the file you need directly:
25
+ Each function is its own module — import the file you need directly. Files
26
+ are grouped by config so a future addition (another DB driver, another fake)
27
+ has an obvious home instead of piling into one flat `src/`:
28
+
29
+ - `sqlite/` — the SQLite/Drizzle/libsql test database and its mocking helper.
30
+ - `file-system/` — the `expo-file-system` fake.
26
31
 
27
32
  ```ts
28
33
  import {
29
34
  createTestDb,
30
35
  type TestDb,
31
- } from "@forthtilliath/expo-test-kit/createTestDb";
32
- import { closeTestDb } from "@forthtilliath/expo-test-kit/closeTestDb";
33
- import { resetTestDb } from "@forthtilliath/expo-test-kit/resetTestDb";
34
- import { mockDbClient } from "@forthtilliath/expo-test-kit/mockDbClient";
36
+ } from "@forthtilliath/expo-test-kit/sqlite/createTestDb";
37
+ import { closeTestDb } from "@forthtilliath/expo-test-kit/sqlite/closeTestDb";
38
+ import { resetTestDb } from "@forthtilliath/expo-test-kit/sqlite/resetTestDb";
39
+ import { mockDbClient } from "@forthtilliath/expo-test-kit/sqlite/mockDbClient";
35
40
  ```
36
41
 
37
42
  ### `createTestDb(schema, migrationsFolder)` / `closeTestDb(db)` / `resetTestDb(db, tables)`
@@ -77,7 +82,7 @@ A minimal in-memory `File`/`Paths` fake — enough to test code that reads/write
77
82
  import {
78
83
  createFakeExpoFileSystem,
79
84
  getFakeExpoFileSystem,
80
- } from "@forthtilliath/expo-test-kit/createFakeExpoFileSystem";
85
+ } from "@forthtilliath/expo-test-kit/file-system/createFakeExpoFileSystem";
81
86
 
82
87
  // jest.mock's factory can't reference an outer variable, so stash + retrieve
83
88
  // instead of closing over one:
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFakeExpoFileSystem.d.ts","sourceRoot":"","sources":["../../src/file-system/createFakeExpoFileSystem.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,KAAK,QAAQ,CAAC;IAC/D,KAAK,EAAE;QAAE,KAAK,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,QAAQ,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC9D;AAWD,wBAAgB,wBAAwB,IAAI,kBAAkB,CAsC7D;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,CAS1D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closeTestDb.d.ts","sourceRoot":"","sources":["../../src/sqlite/closeTestDb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAM/D,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,QAc9D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createTestDb.d.ts","sourceRoot":"","sources":["../../src/sqlite/createTestDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMlE,MAAM,MAAM,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACxD,cAAc,CAAC,OAAO,CAAC,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAKJ,eAAO,MAAM,aAAa,yBAAgC,CAAC;AAS3D,wBAAsB,YAAY,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxE,MAAM,EAAE,OAAO,EACf,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAgB1B"}
@@ -23,6 +23,9 @@ export async function createTestDb(schema, migrationsFolder) {
23
23
  const client = createClient({ url: `file:${dbFile}` });
24
24
  const db = drizzle(client, { schema });
25
25
  await migrate(db, { migrationsFolder });
26
+ // libsql already enables foreign keys by default (on every connection,
27
+ // transactions included — checked by this package's tests); kept explicit
28
+ // so the tests don't silently depend on that default.
26
29
  await client.execute("PRAGMA foreign_keys = ON;");
27
30
  tempFilesByDb.set(db, dbFile);
28
31
  return db;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mockDbClient.d.ts","sourceRoot":"","sources":["../../src/sqlite/mockDbClient.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,KAAK,IAAI,EAC1D,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,QAGhB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resetTestDb.d.ts","sourceRoot":"","sources":["../../src/sqlite/resetTestDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOhD,wBAAsB,WAAW,CAC/B,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACnC,mBAAmB,EAAE,WAAW,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC,CAIf"}
@@ -0,0 +1,104 @@
1
+ export declare const items: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
+ name: "items";
3
+ schema: undefined;
4
+ columns: {
5
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
+ name: "id";
7
+ tableName: "items";
8
+ dataType: "number";
9
+ columnType: "SQLiteInteger";
10
+ data: number;
11
+ driverParam: number;
12
+ notNull: true;
13
+ hasDefault: true;
14
+ isPrimaryKey: true;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: undefined;
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}, {}>;
22
+ name: import("drizzle-orm/sqlite-core").SQLiteColumn<{
23
+ name: "name";
24
+ tableName: "items";
25
+ dataType: "string";
26
+ columnType: "SQLiteText";
27
+ data: string;
28
+ driverParam: string;
29
+ notNull: true;
30
+ hasDefault: false;
31
+ isPrimaryKey: false;
32
+ isAutoincrement: false;
33
+ hasRuntimeDefault: false;
34
+ enumValues: [string, ...string[]];
35
+ baseColumn: never;
36
+ identity: undefined;
37
+ generated: undefined;
38
+ }, {}, {
39
+ length: number | undefined;
40
+ }>;
41
+ };
42
+ dialect: "sqlite";
43
+ }>;
44
+ export declare const tags: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
45
+ name: "tags";
46
+ schema: undefined;
47
+ columns: {
48
+ id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
49
+ name: "id";
50
+ tableName: "tags";
51
+ dataType: "number";
52
+ columnType: "SQLiteInteger";
53
+ data: number;
54
+ driverParam: number;
55
+ notNull: true;
56
+ hasDefault: true;
57
+ isPrimaryKey: true;
58
+ isAutoincrement: false;
59
+ hasRuntimeDefault: false;
60
+ enumValues: undefined;
61
+ baseColumn: never;
62
+ identity: undefined;
63
+ generated: undefined;
64
+ }, {}, {}>;
65
+ itemId: import("drizzle-orm/sqlite-core").SQLiteColumn<{
66
+ name: "item_id";
67
+ tableName: "tags";
68
+ dataType: "number";
69
+ columnType: "SQLiteInteger";
70
+ data: number;
71
+ driverParam: number;
72
+ notNull: true;
73
+ hasDefault: false;
74
+ isPrimaryKey: false;
75
+ isAutoincrement: false;
76
+ hasRuntimeDefault: false;
77
+ enumValues: undefined;
78
+ baseColumn: never;
79
+ identity: undefined;
80
+ generated: undefined;
81
+ }, {}, {}>;
82
+ label: import("drizzle-orm/sqlite-core").SQLiteColumn<{
83
+ name: "label";
84
+ tableName: "tags";
85
+ dataType: "string";
86
+ columnType: "SQLiteText";
87
+ data: string;
88
+ driverParam: string;
89
+ notNull: true;
90
+ hasDefault: false;
91
+ isPrimaryKey: false;
92
+ isAutoincrement: false;
93
+ hasRuntimeDefault: false;
94
+ enumValues: [string, ...string[]];
95
+ baseColumn: never;
96
+ identity: undefined;
97
+ generated: undefined;
98
+ }, {}, {
99
+ length: number | undefined;
100
+ }>;
101
+ };
102
+ dialect: "sqlite";
103
+ }>;
104
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/sqlite/test-fixtures/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGhB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMf,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
2
+ // Minimal fixture schema, only used by this package's own tests to exercise
3
+ // createTestDb/closeTestDb/resetTestDb against a real (temporary) SQLite
4
+ // file — not shipped to consumers.
5
+ export const items = sqliteTable("items", {
6
+ id: integer("id").primaryKey({ autoIncrement: true }),
7
+ name: text("name").notNull(),
8
+ });
9
+ export const tags = sqliteTable("tags", {
10
+ id: integer("id").primaryKey({ autoIncrement: true }),
11
+ itemId: integer("item_id")
12
+ .notNull()
13
+ .references(() => items.id, { onDelete: "restrict" }),
14
+ label: text("label").notNull(),
15
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forthtilliath/expo-test-kit",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -8,11 +8,11 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/Forthtilliath/turborepo.git",
11
+ "url": "https://github.com/Forthtilliath/forthtilliath-packages.git",
12
12
  "directory": "packages/expo-test-kit"
13
13
  },
14
- "homepage": "https://github.com/Forthtilliath/turborepo/tree/main/packages/expo-test-kit#readme",
15
- "bugs": "https://github.com/Forthtilliath/turborepo/issues",
14
+ "homepage": "https://github.com/Forthtilliath/forthtilliath-packages/tree/main/packages/expo-test-kit#readme",
15
+ "bugs": "https://github.com/Forthtilliath/forthtilliath-packages/issues",
16
16
  "files": [
17
17
  "dist"
18
18
  ],
@@ -25,18 +25,18 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@libsql/client": "^0.17.4",
28
- "@types/node": "^26.1.1",
28
+ "@types/node": "^26.2.0",
29
29
  "drizzle-orm": "^0.45.2",
30
30
  "eslint": "10.7.0",
31
31
  "typescript": "^5.9.3",
32
- "vitest": "^4.1.10",
33
- "@forthtilliath/typescript-config": "0.0.0",
34
- "@forthtilliath/eslint-config": "0.0.0"
32
+ "vitest": "^5.0.2",
33
+ "@forthtilliath/eslint-config": "0.8.0",
34
+ "@forthtilliath/typescript-config": "0.1.1"
35
35
  },
36
36
  "scripts": {
37
37
  "lint": "eslint . --max-warnings 0",
38
38
  "check-types": "tsc --noEmit",
39
- "clean": "rm -rf dist",
39
+ "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
40
40
  "dev": "tsc --watch -p tsconfig.build.json",
41
41
  "build": "pnpm run clean && tsc -p tsconfig.build.json",
42
42
  "test": "vitest run",
@@ -1 +0,0 @@
1
- {"version":3,"file":"closeTestDb.d.ts","sourceRoot":"","sources":["../src/closeTestDb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAM/D,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,QAc9D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createFakeExpoFileSystem.d.ts","sourceRoot":"","sources":["../src/createFakeExpoFileSystem.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,CAAC,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,KAAK,QAAQ,CAAC;IAC/D,KAAK,EAAE;QAAE,KAAK,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;QAAC,QAAQ,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CAC9D;AAWD,wBAAgB,wBAAwB,IAAI,kBAAkB,CAsC7D;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,CAS1D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTestDb.d.ts","sourceRoot":"","sources":["../src/createTestDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMlE,MAAM,MAAM,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACxD,cAAc,CAAC,OAAO,CAAC,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAKJ,eAAO,MAAM,aAAa,yBAAgC,CAAC;AAS3D,wBAAsB,YAAY,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxE,MAAM,EAAE,OAAO,EACf,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAa1B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"mockDbClient.d.ts","sourceRoot":"","sources":["../src/mockDbClient.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,KAAK,IAAI,EAC1D,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,OAAO,QAGhB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resetTestDb.d.ts","sourceRoot":"","sources":["../src/resetTestDb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOhD,wBAAsB,WAAW,CAC/B,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACnC,mBAAmB,EAAE,WAAW,EAAE,GACjC,OAAO,CAAC,IAAI,CAAC,CAIf"}
File without changes
File without changes