@geekmidas/testkit 0.0.4 → 0.0.6

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.
Files changed (68) hide show
  1. package/dist/Factory.mjs +1 -1
  2. package/dist/{KyselyFactory-BGvSMLtd.cjs → KyselyFactory-BX7Kv2uP.cjs} +1 -1
  3. package/dist/{KyselyFactory-ionH4gvk.mjs → KyselyFactory-pOMOFQWE.mjs} +2 -2
  4. package/dist/KyselyFactory.cjs +2 -2
  5. package/dist/KyselyFactory.mjs +3 -3
  6. package/dist/{ObjectionFactory-CFrtXe7i.mjs → ObjectionFactory-ChuX8sZN.mjs} +1 -1
  7. package/dist/ObjectionFactory.mjs +2 -2
  8. package/dist/{PostgresKyselyMigrator-CbtiZgfI.mjs → PostgresKyselyMigrator-D8fm35-s.mjs} +1 -1
  9. package/dist/{PostgresKyselyMigrator-Cxf2Dp9y.cjs → PostgresKyselyMigrator-JTY2LfwD.cjs} +2 -2
  10. package/dist/PostgresKyselyMigrator.cjs +2 -2
  11. package/dist/PostgresKyselyMigrator.mjs +2 -2
  12. package/dist/{PostgresMigrator-eqyAFSf-.cjs → PostgresMigrator-Bz-tnjB6.cjs} +1 -1
  13. package/dist/PostgresMigrator.cjs +1 -1
  14. package/dist/PostgresMigrator.mjs +1 -1
  15. package/dist/{VitestKyselyTransactionIsolator-DXjWQtDN.mjs → VitestKyselyTransactionIsolator-D-qpeVKO.mjs} +1 -1
  16. package/dist/{VitestKyselyTransactionIsolator-Dh2AgJDd.cjs → VitestKyselyTransactionIsolator-jF6Ohyu_.cjs} +1 -1
  17. package/dist/VitestKyselyTransactionIsolator.cjs +2 -3
  18. package/dist/VitestKyselyTransactionIsolator.mjs +2 -3
  19. package/dist/{VitestTransactionIsolator-zK5NJ7DQ.cjs → VitestTransactionIsolator-BK9UsrKt.cjs} +4 -2
  20. package/dist/{VitestTransactionIsolator-pLwsDo_A.mjs → VitestTransactionIsolator-e-R3p_X8.mjs} +4 -3
  21. package/dist/VitestTransactionIsolator.cjs +1 -2
  22. package/dist/VitestTransactionIsolator.mjs +1 -2
  23. package/dist/__tests__/Factory.spec.cjs +42 -42
  24. package/dist/__tests__/Factory.spec.mjs +23 -24
  25. package/dist/__tests__/KyselyFactory.spec.cjs +80 -80
  26. package/dist/__tests__/KyselyFactory.spec.mjs +74 -74
  27. package/dist/__tests__/ObjectionFactory.spec.cjs +80 -81
  28. package/dist/__tests__/ObjectionFactory.spec.mjs +52 -53
  29. package/dist/__tests__/PostgresMigrator.spec.cjs +59 -60
  30. package/dist/__tests__/PostgresMigrator.spec.mjs +31 -32
  31. package/dist/__tests__/faker.spec.cjs +60 -60
  32. package/dist/__tests__/faker.spec.mjs +35 -36
  33. package/dist/__tests__/integration.spec.cjs +44 -41
  34. package/dist/__tests__/integration.spec.mjs +45 -43
  35. package/dist/{chunk-DWy1uDak.cjs → chunk-CUT6urMc.cjs} +0 -9
  36. package/dist/example.cjs +2 -2
  37. package/dist/example.mjs +3 -3
  38. package/dist/{faker-h6CkRloU.cjs → faker-caz-8zt8.cjs} +1 -1
  39. package/dist/faker.cjs +1 -1
  40. package/dist/faker.mjs +1 -1
  41. package/dist/{helpers-C2NH7xcz.cjs → helpers-B2CfbaTC.cjs} +1 -1
  42. package/dist/helpers-DN4sJO4i.mjs +13 -0
  43. package/dist/helpers-DOtYCEvZ.cjs +19 -0
  44. package/dist/helpers.cjs +2 -6
  45. package/dist/helpers.mjs +2 -5
  46. package/dist/kysely-C1-aHdnU.mjs +11 -0
  47. package/dist/kysely-DL3C2eM4.cjs +16 -0
  48. package/dist/kysely.cjs +8 -15
  49. package/dist/kysely.mjs +8 -15
  50. package/dist/objection.mjs +2 -2
  51. package/package.json +2 -1
  52. package/src/VitestTransactionIsolator.ts +4 -2
  53. package/src/__tests__/KyselyFactory.spec.ts +4 -6
  54. package/src/__tests__/integration.spec.ts +8 -3
  55. package/src/helpers.ts +1 -18
  56. package/src/kysely.ts +3 -1
  57. package/dist/dist-BM2KvLG1.mjs +0 -5618
  58. package/dist/dist-DE3gAxQI.cjs +0 -5736
  59. package/dist/helpers-BnARb5Ap.mjs +0 -19
  60. package/dist/helpers-C_RZk04R.cjs +0 -31
  61. package/dist/magic-string.es-C6yzoryu.mjs +0 -1014
  62. package/dist/magic-string.es-jdtJrR0A.cjs +0 -1015
  63. package/dist/vi.bdSIJ99Y-BgRxGeO2.mjs +0 -9382
  64. package/dist/vi.bdSIJ99Y-CFuzUeY6.cjs +0 -9393
  65. /package/dist/{Factory-D52Lsc6Z.mjs → Factory-DlzMkMzb.mjs} +0 -0
  66. /package/dist/{PostgresMigrator-DqeuPy-e.mjs → PostgresMigrator-CEoRKTdq.mjs} +0 -0
  67. /package/dist/{faker-cGCFcrj2.mjs → faker-BwaXA_RF.mjs} +0 -0
  68. /package/dist/{helpers-CukcFAU9.mjs → helpers-Rf5F71r9.mjs} +0 -0
@@ -1,60 +1,60 @@
1
- const require_chunk = require('../chunk-DWy1uDak.cjs');
1
+ const require_chunk = require('../chunk-CUT6urMc.cjs');
2
2
  require('../Factory-DREHoms3.cjs');
3
- require('../faker-h6CkRloU.cjs');
4
- const require_KyselyFactory = require('../KyselyFactory-BGvSMLtd.cjs');
5
- const require_dist = require('../dist-DE3gAxQI.cjs');
6
- const require_vi_bdSIJ99Y = require('../vi.bdSIJ99Y-CFuzUeY6.cjs');
7
- require('../VitestTransactionIsolator-zK5NJ7DQ.cjs');
8
- require('../VitestKyselyTransactionIsolator-Dh2AgJDd.cjs');
9
- const require_helpers = require('../helpers-C_RZk04R.cjs');
10
- const require_helpers$1 = require('../helpers-C2NH7xcz.cjs');
3
+ require('../faker-caz-8zt8.cjs');
4
+ const require_KyselyFactory = require('../KyselyFactory-BX7Kv2uP.cjs');
5
+ require('../PostgresMigrator-Bz-tnjB6.cjs');
6
+ require('../PostgresKyselyMigrator-JTY2LfwD.cjs');
7
+ require('../VitestTransactionIsolator-BK9UsrKt.cjs');
8
+ require('../VitestKyselyTransactionIsolator-jF6Ohyu_.cjs');
9
+ const require_helpers = require('../helpers-DOtYCEvZ.cjs');
10
+ const require_kysely = require('../kysely-DL3C2eM4.cjs');
11
+ const require_helpers$1 = require('../helpers-B2CfbaTC.cjs');
11
12
  const pg = require_chunk.__toESM(require("pg"));
13
+ const vitest = require_chunk.__toESM(require("vitest"));
12
14
 
13
15
  //#region src/__tests__/KyselyFactory.spec.ts
14
16
  const db = require_helpers.createKyselyDb(require_helpers$1.TEST_DATABASE_CONFIG);
15
- const itWithTransaction = require_helpers.wrapVitestKyselyTransaction(db, require_helpers$1.createTestTables);
17
+ const itWithTransaction = require_kysely.wrapVitestKyselyTransaction(vitest.it, db, require_helpers$1.createTestTables);
16
18
  const int8TypeId = 20;
17
19
  pg.default.types.setTypeParser(int8TypeId, (val) => {
18
20
  return parseInt(val, 10);
19
21
  });
20
- require_dist.describe("KyselyFactory", () => {
21
- let db$1;
22
- let trx;
23
- require_dist.describe("KyselyFactory.insert", () => {
24
- itWithTransaction("should insert a record with defaults", async ({ trx: trx$1 }) => {
22
+ (0, vitest.describe)("KyselyFactory", () => {
23
+ (0, vitest.describe)("KyselyFactory.insert", () => {
24
+ itWithTransaction("should insert a record with defaults", async ({ trx }) => {
25
25
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
26
26
  name: "John Doe",
27
27
  email: `user${Date.now()}@example.com`,
28
28
  createdAt: /* @__PURE__ */ new Date()
29
29
  }));
30
30
  const builders = { user: userBuilder };
31
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
31
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
32
32
  const user = await factory.insert("user");
33
- require_vi_bdSIJ99Y.globalExpect(user).toBeDefined();
34
- require_vi_bdSIJ99Y.globalExpect(user.id).toBeDefined();
35
- require_vi_bdSIJ99Y.globalExpect(user.name).toBe("John Doe");
36
- require_vi_bdSIJ99Y.globalExpect(user.email).toContain("user");
37
- require_vi_bdSIJ99Y.globalExpect(user.email).toContain("@example.com");
38
- require_vi_bdSIJ99Y.globalExpect(user.createdAt).toBeInstanceOf(Date);
33
+ (0, vitest.expect)(user).toBeDefined();
34
+ (0, vitest.expect)(user.id).toBeDefined();
35
+ (0, vitest.expect)(user.name).toBe("John Doe");
36
+ (0, vitest.expect)(user.email).toContain("user");
37
+ (0, vitest.expect)(user.email).toContain("@example.com");
38
+ (0, vitest.expect)(user.createdAt).toBeInstanceOf(Date);
39
39
  });
40
- itWithTransaction("should override defaults with provided attributes", async ({ trx: trx$1 }) => {
40
+ itWithTransaction("should override defaults with provided attributes", async ({ trx }) => {
41
41
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
42
42
  name: "John Doe",
43
43
  email: `user${Date.now()}@example.com`,
44
44
  createdAt: /* @__PURE__ */ new Date()
45
45
  }));
46
46
  const builders = { user: userBuilder };
47
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
47
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
48
48
  const customEmail = "custom@test.com";
49
49
  const customName = "Jane Smith";
50
50
  const user = await factory.insert("user", {
51
51
  email: customEmail,
52
52
  name: customName
53
53
  });
54
- require_vi_bdSIJ99Y.globalExpect(user.name).toBe(customName);
55
- require_vi_bdSIJ99Y.globalExpect(user.email).toBe(customEmail);
54
+ (0, vitest.expect)(user.name).toBe(customName);
55
+ (0, vitest.expect)(user.email).toBe(customEmail);
56
56
  });
57
- itWithTransaction("should handle relations", async ({ trx: trx$1 }) => {
57
+ itWithTransaction("should handle relations", async ({ trx }) => {
58
58
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
59
59
  name: "John Doe",
60
60
  email: `user${Date.now()}@example.com`,
@@ -80,55 +80,55 @@ require_dist.describe("KyselyFactory", () => {
80
80
  user: userBuilder,
81
81
  post: postBuilder
82
82
  };
83
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
83
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
84
84
  const post = await factory.insert("post", { title: "Test Post" });
85
- require_vi_bdSIJ99Y.globalExpect(post).toBeDefined();
86
- require_vi_bdSIJ99Y.globalExpect(post.title).toBe("Test Post");
87
- require_vi_bdSIJ99Y.globalExpect(post.userId).toBeDefined();
88
- require_vi_bdSIJ99Y.globalExpect(typeof post.userId).toBe("number");
85
+ (0, vitest.expect)(post).toBeDefined();
86
+ (0, vitest.expect)(post.title).toBe("Test Post");
87
+ (0, vitest.expect)(post.userId).toBeDefined();
88
+ (0, vitest.expect)(typeof post.userId).toBe("number");
89
89
  });
90
- itWithTransaction("should throw error for non-existent builder", async ({ trx: trx$1 }) => {
91
- const factory = new require_KyselyFactory.KyselyFactory({}, {}, trx$1);
92
- await require_vi_bdSIJ99Y.globalExpect(factory.insert("nonExistent")).rejects.toThrow("Factory \"nonExistent\" does not exist");
90
+ itWithTransaction("should throw error for non-existent builder", async ({ trx }) => {
91
+ const factory = new require_KyselyFactory.KyselyFactory({}, {}, trx);
92
+ await (0, vitest.expect)(factory.insert("nonExistent")).rejects.toThrow("Factory \"nonExistent\" does not exist");
93
93
  });
94
94
  });
95
- require_dist.describe("KyselyFactory.insertMany", () => {
96
- itWithTransaction("should insert multiple records with same attributes", async ({ trx: trx$1 }) => {
95
+ (0, vitest.describe)("KyselyFactory.insertMany", () => {
96
+ itWithTransaction("should insert multiple records with same attributes", async ({ trx }) => {
97
97
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
98
98
  name: "John Doe",
99
99
  email: `user${Date.now()}-${Math.random()}@example.com`,
100
100
  createdAt: /* @__PURE__ */ new Date()
101
101
  }));
102
102
  const builders = { user: userBuilder };
103
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
103
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
104
104
  const users = await factory.insertMany(3, "user");
105
- require_vi_bdSIJ99Y.globalExpect(users).toHaveLength(3);
105
+ (0, vitest.expect)(users).toHaveLength(3);
106
106
  users.forEach((user, index) => {
107
- require_vi_bdSIJ99Y.globalExpect(user.id).toBeDefined();
108
- require_vi_bdSIJ99Y.globalExpect(user.name).toBe("John Doe");
109
- require_vi_bdSIJ99Y.globalExpect(user.email).toContain("@example.com");
107
+ (0, vitest.expect)(user.id).toBeDefined();
108
+ (0, vitest.expect)(user.name).toBe("John Doe");
109
+ (0, vitest.expect)(user.email).toContain("@example.com");
110
110
  });
111
111
  });
112
- itWithTransaction("should insert multiple records with dynamic attributes", async ({ trx: trx$1 }) => {
112
+ itWithTransaction("should insert multiple records with dynamic attributes", async ({ trx }) => {
113
113
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
114
114
  email: `user${Date.now()}-${Math.random()}@example.com`,
115
115
  createdAt: /* @__PURE__ */ new Date()
116
116
  }));
117
117
  const builders = { user: userBuilder };
118
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
118
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
119
119
  const users = await factory.insertMany(3, "user", (idx) => ({ name: `User ${idx}` }));
120
- require_vi_bdSIJ99Y.globalExpect(users).toHaveLength(3);
120
+ (0, vitest.expect)(users).toHaveLength(3);
121
121
  users.forEach((user, index) => {
122
- require_vi_bdSIJ99Y.globalExpect(user.name).toBe(`User ${index}`);
122
+ (0, vitest.expect)(user.name).toBe(`User ${index}`);
123
123
  });
124
124
  });
125
- itWithTransaction("should throw error for non-existent builder", async ({ trx: trx$1 }) => {
126
- const factory = new require_KyselyFactory.KyselyFactory({}, {}, trx$1);
127
- await require_vi_bdSIJ99Y.globalExpect(factory.insertMany(2, "nonExistent")).rejects.toThrow("Builder \"nonExistent\" is not registered");
125
+ itWithTransaction("should throw error for non-existent builder", async ({ trx }) => {
126
+ const factory = new require_KyselyFactory.KyselyFactory({}, {}, trx);
127
+ await (0, vitest.expect)(factory.insertMany(2, "nonExistent")).rejects.toThrow("Builder \"nonExistent\" is not registered");
128
128
  });
129
129
  });
130
- require_dist.describe("KyselyFactory.createBuilder", () => {
131
- itWithTransaction("should work with async defaults", async ({ trx: trx$1 }) => {
130
+ (0, vitest.describe)("KyselyFactory.createBuilder", () => {
131
+ itWithTransaction("should work with async defaults", async ({ trx }) => {
132
132
  let counter = 0;
133
133
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => {
134
134
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -140,71 +140,71 @@ require_dist.describe("KyselyFactory", () => {
140
140
  };
141
141
  });
142
142
  const builders = { user: userBuilder };
143
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
143
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
144
144
  const user1 = await factory.insert("user");
145
145
  const user2 = await factory.insert("user");
146
- require_vi_bdSIJ99Y.globalExpect(user1.name).toBe("Async User 1");
147
- require_vi_bdSIJ99Y.globalExpect(user2.name).toBe("Async User 2");
146
+ (0, vitest.expect)(user1.name).toBe("Async User 1");
147
+ (0, vitest.expect)(user2.name).toBe("Async User 2");
148
148
  });
149
149
  });
150
- require_dist.describe("KyselyFactory.seed", () => {
151
- itWithTransaction("should execute seed functions", async ({ trx: trx$1 }) => {
150
+ (0, vitest.describe)("KyselyFactory.seed", () => {
151
+ itWithTransaction("should execute seed functions", async ({ trx }) => {
152
152
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
153
153
  name: "John Doe",
154
154
  email: `user${Date.now()}@example.com`,
155
155
  createdAt: /* @__PURE__ */ new Date()
156
156
  }));
157
157
  const builders = { user: userBuilder };
158
- const seeds = { createAdminUser: require_KyselyFactory.KyselyFactory.createSeed(async (attrs, factory$1, db$2) => {
158
+ const seeds = { createAdminUser: require_KyselyFactory.KyselyFactory.createSeed(async (attrs, factory$1, db$1) => {
159
159
  return await factory$1.insert("user", {
160
160
  name: attrs.name || "Admin User",
161
161
  email: "admin@example.com"
162
162
  });
163
163
  }) };
164
- const factory = new require_KyselyFactory.KyselyFactory(builders, seeds, trx$1);
164
+ const factory = new require_KyselyFactory.KyselyFactory(builders, seeds, trx);
165
165
  const adminUser = await factory.seed("createAdminUser");
166
- require_vi_bdSIJ99Y.globalExpect(adminUser).toBeDefined();
167
- require_vi_bdSIJ99Y.globalExpect(adminUser.name).toBe("Admin User");
168
- require_vi_bdSIJ99Y.globalExpect(adminUser.email).toBe("admin@example.com");
166
+ (0, vitest.expect)(adminUser).toBeDefined();
167
+ (0, vitest.expect)(adminUser.name).toBe("Admin User");
168
+ (0, vitest.expect)(adminUser.email).toBe("admin@example.com");
169
169
  });
170
- itWithTransaction("should pass attributes to seed functions", async ({ trx: trx$1 }) => {
170
+ itWithTransaction("should pass attributes to seed functions", async ({ trx }) => {
171
171
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
172
172
  name: "John Doe",
173
173
  email: `user${Date.now()}@example.com`,
174
174
  createdAt: /* @__PURE__ */ new Date()
175
175
  }));
176
176
  const builders = { user: userBuilder };
177
- const seeds = { createCustomUser: require_KyselyFactory.KyselyFactory.createSeed(async (attrs, factory$1, db$2) => {
177
+ const seeds = { createCustomUser: require_KyselyFactory.KyselyFactory.createSeed(async (attrs, factory$1, db$1) => {
178
178
  return await factory$1.insert("user", attrs);
179
179
  }) };
180
- const factory = new require_KyselyFactory.KyselyFactory(builders, seeds, trx$1);
180
+ const factory = new require_KyselyFactory.KyselyFactory(builders, seeds, trx);
181
181
  const customUser = await factory.seed("createCustomUser", {
182
182
  name: "Custom User",
183
183
  email: "custom@test.com"
184
184
  });
185
- require_vi_bdSIJ99Y.globalExpect(customUser.name).toBe("Custom User");
186
- require_vi_bdSIJ99Y.globalExpect(customUser.email).toBe("custom@test.com");
185
+ (0, vitest.expect)(customUser.name).toBe("Custom User");
186
+ (0, vitest.expect)(customUser.email).toBe("custom@test.com");
187
187
  });
188
- itWithTransaction("should throw error for non-existent seed", async ({ trx: trx$1 }) => {
189
- const factory = new require_KyselyFactory.KyselyFactory({}, {}, trx$1);
190
- require_vi_bdSIJ99Y.globalExpect(() => factory.seed("nonExistent")).toThrow("Seed \"nonExistent\" is not registered");
188
+ itWithTransaction("should throw error for non-existent seed", async ({ trx }) => {
189
+ const factory = new require_KyselyFactory.KyselyFactory({}, {}, trx);
190
+ (0, vitest.expect)(() => factory.seed("nonExistent")).toThrow("Seed \"nonExistent\" is not registered");
191
191
  });
192
192
  });
193
- require_dist.describe("Factory integration", () => {
194
- itWithTransaction("should work with controlled transactions", async ({ trx: trx$1 }) => {
193
+ (0, vitest.describe)("Factory integration", () => {
194
+ itWithTransaction("should work with controlled transactions", async ({ trx }) => {
195
195
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
196
196
  name: "John Doe",
197
197
  email: `user${Date.now()}@example.com`,
198
198
  createdAt: /* @__PURE__ */ new Date()
199
199
  }));
200
200
  const builders = { user: userBuilder };
201
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
201
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
202
202
  const user = await factory.insert("user");
203
- const foundUser = await trx$1.selectFrom("users").selectAll().where("id", "=", user.id).executeTakeFirst();
204
- require_vi_bdSIJ99Y.globalExpect(foundUser).toBeDefined();
205
- require_vi_bdSIJ99Y.globalExpect(foundUser?.id).toBe(user.id);
203
+ const foundUser = await trx.selectFrom("users").selectAll().where("id", "=", user.id).executeTakeFirst();
204
+ (0, vitest.expect)(foundUser).toBeDefined();
205
+ (0, vitest.expect)(foundUser?.id).toBe(user.id);
206
206
  });
207
- itWithTransaction("should work with factory passed to defaults", async ({ trx: trx$1 }) => {
207
+ itWithTransaction("should work with factory passed to defaults", async ({ trx }) => {
208
208
  const userBuilder = require_KyselyFactory.KyselyFactory.createBuilder("users", async (attrs) => ({
209
209
  name: "John Doe",
210
210
  email: `user${Date.now()}@example.com`,
@@ -223,11 +223,11 @@ require_dist.describe("KyselyFactory", () => {
223
223
  user: userBuilder,
224
224
  post: postBuilder
225
225
  };
226
- const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx$1);
226
+ const factory = new require_KyselyFactory.KyselyFactory(builders, {}, trx);
227
227
  const post = await factory.insert("post");
228
- require_vi_bdSIJ99Y.globalExpect(post.userId).toBeDefined();
229
- const relatedUser = await trx$1.selectFrom("users").selectAll().where("id", "=", post.userId).executeTakeFirst();
230
- require_vi_bdSIJ99Y.globalExpect(relatedUser).toBeDefined();
228
+ (0, vitest.expect)(post.userId).toBeDefined();
229
+ const relatedUser = await trx.selectFrom("users").selectAll().where("id", "=", post.userId).executeTakeFirst();
230
+ (0, vitest.expect)(relatedUser).toBeDefined();
231
231
  });
232
232
  });
233
233
  });
@@ -1,59 +1,59 @@
1
- import { describe } from "../dist-BM2KvLG1.mjs";
2
- import "../Factory-D52Lsc6Z.mjs";
3
- import "../faker-cGCFcrj2.mjs";
4
- import { KyselyFactory } from "../KyselyFactory-ionH4gvk.mjs";
5
- import { globalExpect } from "../vi.bdSIJ99Y-BgRxGeO2.mjs";
6
- import "../VitestTransactionIsolator-pLwsDo_A.mjs";
7
- import "../VitestKyselyTransactionIsolator-DXjWQtDN.mjs";
8
- import { createKyselyDb, wrapVitestKyselyTransaction } from "../helpers-BnARb5Ap.mjs";
9
- import { TEST_DATABASE_CONFIG, createTestTables } from "../helpers-CukcFAU9.mjs";
1
+ import "../Factory-DlzMkMzb.mjs";
2
+ import "../faker-BwaXA_RF.mjs";
3
+ import { KyselyFactory } from "../KyselyFactory-pOMOFQWE.mjs";
4
+ import "../PostgresMigrator-CEoRKTdq.mjs";
5
+ import "../PostgresKyselyMigrator-D8fm35-s.mjs";
6
+ import "../VitestTransactionIsolator-e-R3p_X8.mjs";
7
+ import "../VitestKyselyTransactionIsolator-D-qpeVKO.mjs";
8
+ import { createKyselyDb } from "../helpers-DN4sJO4i.mjs";
9
+ import { wrapVitestKyselyTransaction } from "../kysely-C1-aHdnU.mjs";
10
+ import { TEST_DATABASE_CONFIG, createTestTables } from "../helpers-Rf5F71r9.mjs";
10
11
  import pg from "pg";
12
+ import { describe, expect, it } from "vitest";
11
13
 
12
14
  //#region src/__tests__/KyselyFactory.spec.ts
13
15
  const db = createKyselyDb(TEST_DATABASE_CONFIG);
14
- const itWithTransaction = wrapVitestKyselyTransaction(db, createTestTables);
16
+ const itWithTransaction = wrapVitestKyselyTransaction(it, db, createTestTables);
15
17
  const int8TypeId = 20;
16
18
  pg.types.setTypeParser(int8TypeId, (val) => {
17
19
  return parseInt(val, 10);
18
20
  });
19
21
  describe("KyselyFactory", () => {
20
- let db$1;
21
- let trx;
22
22
  describe("KyselyFactory.insert", () => {
23
- itWithTransaction("should insert a record with defaults", async ({ trx: trx$1 }) => {
23
+ itWithTransaction("should insert a record with defaults", async ({ trx }) => {
24
24
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
25
25
  name: "John Doe",
26
26
  email: `user${Date.now()}@example.com`,
27
27
  createdAt: /* @__PURE__ */ new Date()
28
28
  }));
29
29
  const builders = { user: userBuilder };
30
- const factory = new KyselyFactory(builders, {}, trx$1);
30
+ const factory = new KyselyFactory(builders, {}, trx);
31
31
  const user = await factory.insert("user");
32
- globalExpect(user).toBeDefined();
33
- globalExpect(user.id).toBeDefined();
34
- globalExpect(user.name).toBe("John Doe");
35
- globalExpect(user.email).toContain("user");
36
- globalExpect(user.email).toContain("@example.com");
37
- globalExpect(user.createdAt).toBeInstanceOf(Date);
32
+ expect(user).toBeDefined();
33
+ expect(user.id).toBeDefined();
34
+ expect(user.name).toBe("John Doe");
35
+ expect(user.email).toContain("user");
36
+ expect(user.email).toContain("@example.com");
37
+ expect(user.createdAt).toBeInstanceOf(Date);
38
38
  });
39
- itWithTransaction("should override defaults with provided attributes", async ({ trx: trx$1 }) => {
39
+ itWithTransaction("should override defaults with provided attributes", async ({ trx }) => {
40
40
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
41
41
  name: "John Doe",
42
42
  email: `user${Date.now()}@example.com`,
43
43
  createdAt: /* @__PURE__ */ new Date()
44
44
  }));
45
45
  const builders = { user: userBuilder };
46
- const factory = new KyselyFactory(builders, {}, trx$1);
46
+ const factory = new KyselyFactory(builders, {}, trx);
47
47
  const customEmail = "custom@test.com";
48
48
  const customName = "Jane Smith";
49
49
  const user = await factory.insert("user", {
50
50
  email: customEmail,
51
51
  name: customName
52
52
  });
53
- globalExpect(user.name).toBe(customName);
54
- globalExpect(user.email).toBe(customEmail);
53
+ expect(user.name).toBe(customName);
54
+ expect(user.email).toBe(customEmail);
55
55
  });
56
- itWithTransaction("should handle relations", async ({ trx: trx$1 }) => {
56
+ itWithTransaction("should handle relations", async ({ trx }) => {
57
57
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
58
58
  name: "John Doe",
59
59
  email: `user${Date.now()}@example.com`,
@@ -79,55 +79,55 @@ describe("KyselyFactory", () => {
79
79
  user: userBuilder,
80
80
  post: postBuilder
81
81
  };
82
- const factory = new KyselyFactory(builders, {}, trx$1);
82
+ const factory = new KyselyFactory(builders, {}, trx);
83
83
  const post = await factory.insert("post", { title: "Test Post" });
84
- globalExpect(post).toBeDefined();
85
- globalExpect(post.title).toBe("Test Post");
86
- globalExpect(post.userId).toBeDefined();
87
- globalExpect(typeof post.userId).toBe("number");
84
+ expect(post).toBeDefined();
85
+ expect(post.title).toBe("Test Post");
86
+ expect(post.userId).toBeDefined();
87
+ expect(typeof post.userId).toBe("number");
88
88
  });
89
- itWithTransaction("should throw error for non-existent builder", async ({ trx: trx$1 }) => {
90
- const factory = new KyselyFactory({}, {}, trx$1);
91
- await globalExpect(factory.insert("nonExistent")).rejects.toThrow("Factory \"nonExistent\" does not exist");
89
+ itWithTransaction("should throw error for non-existent builder", async ({ trx }) => {
90
+ const factory = new KyselyFactory({}, {}, trx);
91
+ await expect(factory.insert("nonExistent")).rejects.toThrow("Factory \"nonExistent\" does not exist");
92
92
  });
93
93
  });
94
94
  describe("KyselyFactory.insertMany", () => {
95
- itWithTransaction("should insert multiple records with same attributes", async ({ trx: trx$1 }) => {
95
+ itWithTransaction("should insert multiple records with same attributes", async ({ trx }) => {
96
96
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
97
97
  name: "John Doe",
98
98
  email: `user${Date.now()}-${Math.random()}@example.com`,
99
99
  createdAt: /* @__PURE__ */ new Date()
100
100
  }));
101
101
  const builders = { user: userBuilder };
102
- const factory = new KyselyFactory(builders, {}, trx$1);
102
+ const factory = new KyselyFactory(builders, {}, trx);
103
103
  const users = await factory.insertMany(3, "user");
104
- globalExpect(users).toHaveLength(3);
104
+ expect(users).toHaveLength(3);
105
105
  users.forEach((user, index) => {
106
- globalExpect(user.id).toBeDefined();
107
- globalExpect(user.name).toBe("John Doe");
108
- globalExpect(user.email).toContain("@example.com");
106
+ expect(user.id).toBeDefined();
107
+ expect(user.name).toBe("John Doe");
108
+ expect(user.email).toContain("@example.com");
109
109
  });
110
110
  });
111
- itWithTransaction("should insert multiple records with dynamic attributes", async ({ trx: trx$1 }) => {
111
+ itWithTransaction("should insert multiple records with dynamic attributes", async ({ trx }) => {
112
112
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
113
113
  email: `user${Date.now()}-${Math.random()}@example.com`,
114
114
  createdAt: /* @__PURE__ */ new Date()
115
115
  }));
116
116
  const builders = { user: userBuilder };
117
- const factory = new KyselyFactory(builders, {}, trx$1);
117
+ const factory = new KyselyFactory(builders, {}, trx);
118
118
  const users = await factory.insertMany(3, "user", (idx) => ({ name: `User ${idx}` }));
119
- globalExpect(users).toHaveLength(3);
119
+ expect(users).toHaveLength(3);
120
120
  users.forEach((user, index) => {
121
- globalExpect(user.name).toBe(`User ${index}`);
121
+ expect(user.name).toBe(`User ${index}`);
122
122
  });
123
123
  });
124
- itWithTransaction("should throw error for non-existent builder", async ({ trx: trx$1 }) => {
125
- const factory = new KyselyFactory({}, {}, trx$1);
126
- await globalExpect(factory.insertMany(2, "nonExistent")).rejects.toThrow("Builder \"nonExistent\" is not registered");
124
+ itWithTransaction("should throw error for non-existent builder", async ({ trx }) => {
125
+ const factory = new KyselyFactory({}, {}, trx);
126
+ await expect(factory.insertMany(2, "nonExistent")).rejects.toThrow("Builder \"nonExistent\" is not registered");
127
127
  });
128
128
  });
129
129
  describe("KyselyFactory.createBuilder", () => {
130
- itWithTransaction("should work with async defaults", async ({ trx: trx$1 }) => {
130
+ itWithTransaction("should work with async defaults", async ({ trx }) => {
131
131
  let counter = 0;
132
132
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => {
133
133
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -139,71 +139,71 @@ describe("KyselyFactory", () => {
139
139
  };
140
140
  });
141
141
  const builders = { user: userBuilder };
142
- const factory = new KyselyFactory(builders, {}, trx$1);
142
+ const factory = new KyselyFactory(builders, {}, trx);
143
143
  const user1 = await factory.insert("user");
144
144
  const user2 = await factory.insert("user");
145
- globalExpect(user1.name).toBe("Async User 1");
146
- globalExpect(user2.name).toBe("Async User 2");
145
+ expect(user1.name).toBe("Async User 1");
146
+ expect(user2.name).toBe("Async User 2");
147
147
  });
148
148
  });
149
149
  describe("KyselyFactory.seed", () => {
150
- itWithTransaction("should execute seed functions", async ({ trx: trx$1 }) => {
150
+ itWithTransaction("should execute seed functions", async ({ trx }) => {
151
151
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
152
152
  name: "John Doe",
153
153
  email: `user${Date.now()}@example.com`,
154
154
  createdAt: /* @__PURE__ */ new Date()
155
155
  }));
156
156
  const builders = { user: userBuilder };
157
- const seeds = { createAdminUser: KyselyFactory.createSeed(async (attrs, factory$1, db$2) => {
157
+ const seeds = { createAdminUser: KyselyFactory.createSeed(async (attrs, factory$1, db$1) => {
158
158
  return await factory$1.insert("user", {
159
159
  name: attrs.name || "Admin User",
160
160
  email: "admin@example.com"
161
161
  });
162
162
  }) };
163
- const factory = new KyselyFactory(builders, seeds, trx$1);
163
+ const factory = new KyselyFactory(builders, seeds, trx);
164
164
  const adminUser = await factory.seed("createAdminUser");
165
- globalExpect(adminUser).toBeDefined();
166
- globalExpect(adminUser.name).toBe("Admin User");
167
- globalExpect(adminUser.email).toBe("admin@example.com");
165
+ expect(adminUser).toBeDefined();
166
+ expect(adminUser.name).toBe("Admin User");
167
+ expect(adminUser.email).toBe("admin@example.com");
168
168
  });
169
- itWithTransaction("should pass attributes to seed functions", async ({ trx: trx$1 }) => {
169
+ itWithTransaction("should pass attributes to seed functions", async ({ trx }) => {
170
170
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
171
171
  name: "John Doe",
172
172
  email: `user${Date.now()}@example.com`,
173
173
  createdAt: /* @__PURE__ */ new Date()
174
174
  }));
175
175
  const builders = { user: userBuilder };
176
- const seeds = { createCustomUser: KyselyFactory.createSeed(async (attrs, factory$1, db$2) => {
176
+ const seeds = { createCustomUser: KyselyFactory.createSeed(async (attrs, factory$1, db$1) => {
177
177
  return await factory$1.insert("user", attrs);
178
178
  }) };
179
- const factory = new KyselyFactory(builders, seeds, trx$1);
179
+ const factory = new KyselyFactory(builders, seeds, trx);
180
180
  const customUser = await factory.seed("createCustomUser", {
181
181
  name: "Custom User",
182
182
  email: "custom@test.com"
183
183
  });
184
- globalExpect(customUser.name).toBe("Custom User");
185
- globalExpect(customUser.email).toBe("custom@test.com");
184
+ expect(customUser.name).toBe("Custom User");
185
+ expect(customUser.email).toBe("custom@test.com");
186
186
  });
187
- itWithTransaction("should throw error for non-existent seed", async ({ trx: trx$1 }) => {
188
- const factory = new KyselyFactory({}, {}, trx$1);
189
- globalExpect(() => factory.seed("nonExistent")).toThrow("Seed \"nonExistent\" is not registered");
187
+ itWithTransaction("should throw error for non-existent seed", async ({ trx }) => {
188
+ const factory = new KyselyFactory({}, {}, trx);
189
+ expect(() => factory.seed("nonExistent")).toThrow("Seed \"nonExistent\" is not registered");
190
190
  });
191
191
  });
192
192
  describe("Factory integration", () => {
193
- itWithTransaction("should work with controlled transactions", async ({ trx: trx$1 }) => {
193
+ itWithTransaction("should work with controlled transactions", async ({ trx }) => {
194
194
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
195
195
  name: "John Doe",
196
196
  email: `user${Date.now()}@example.com`,
197
197
  createdAt: /* @__PURE__ */ new Date()
198
198
  }));
199
199
  const builders = { user: userBuilder };
200
- const factory = new KyselyFactory(builders, {}, trx$1);
200
+ const factory = new KyselyFactory(builders, {}, trx);
201
201
  const user = await factory.insert("user");
202
- const foundUser = await trx$1.selectFrom("users").selectAll().where("id", "=", user.id).executeTakeFirst();
203
- globalExpect(foundUser).toBeDefined();
204
- globalExpect(foundUser?.id).toBe(user.id);
202
+ const foundUser = await trx.selectFrom("users").selectAll().where("id", "=", user.id).executeTakeFirst();
203
+ expect(foundUser).toBeDefined();
204
+ expect(foundUser?.id).toBe(user.id);
205
205
  });
206
- itWithTransaction("should work with factory passed to defaults", async ({ trx: trx$1 }) => {
206
+ itWithTransaction("should work with factory passed to defaults", async ({ trx }) => {
207
207
  const userBuilder = KyselyFactory.createBuilder("users", async (attrs) => ({
208
208
  name: "John Doe",
209
209
  email: `user${Date.now()}@example.com`,
@@ -222,11 +222,11 @@ describe("KyselyFactory", () => {
222
222
  user: userBuilder,
223
223
  post: postBuilder
224
224
  };
225
- const factory = new KyselyFactory(builders, {}, trx$1);
225
+ const factory = new KyselyFactory(builders, {}, trx);
226
226
  const post = await factory.insert("post");
227
- globalExpect(post.userId).toBeDefined();
228
- const relatedUser = await trx$1.selectFrom("users").selectAll().where("id", "=", post.userId).executeTakeFirst();
229
- globalExpect(relatedUser).toBeDefined();
227
+ expect(post.userId).toBeDefined();
228
+ const relatedUser = await trx.selectFrom("users").selectAll().where("id", "=", post.userId).executeTakeFirst();
229
+ expect(relatedUser).toBeDefined();
230
230
  });
231
231
  });
232
232
  });