jcc-express-mvc 1.8.28 → 1.8.29

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 (37) hide show
  1. package/__tests__/ApplicationBuilder.test.js +105 -26
  2. package/__tests__/Container.test.js +191 -51
  3. package/__tests__/Job.test.js +70 -0
  4. package/__tests__/MySqlSchemaBlueprint.test.js +285 -26
  5. package/__tests__/Str.test.d.ts +2 -0
  6. package/__tests__/Str.test.d.ts.map +1 -0
  7. package/__tests__/Str.test.js +665 -0
  8. package/__tests__/ValidationException.test.js +48 -11
  9. package/lib/Command-Line/MakeCommand.d.ts +4 -0
  10. package/lib/Command-Line/MakeCommand.d.ts.map +1 -1
  11. package/lib/Command-Line/MakeCommand.js +101 -0
  12. package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
  13. package/lib/Command-Line/NodeArtisanCommand.js +12 -1
  14. package/lib/Command-Line/files/Action.d.ts +3 -0
  15. package/lib/Command-Line/files/Action.d.ts.map +1 -0
  16. package/lib/Command-Line/files/Action.js +12 -0
  17. package/lib/Command-Line/files/Dto.d.ts +3 -0
  18. package/lib/Command-Line/files/Dto.d.ts.map +1 -0
  19. package/lib/Command-Line/files/Dto.js +20 -0
  20. package/lib/Command-Line/files/Repository.d.ts +3 -0
  21. package/lib/Command-Line/files/Repository.d.ts.map +1 -0
  22. package/lib/Command-Line/files/Repository.js +34 -0
  23. package/lib/Command-Line/files/Service.d.ts +3 -0
  24. package/lib/Command-Line/files/Service.d.ts.map +1 -0
  25. package/lib/Command-Line/files/Service.js +8 -0
  26. package/lib/Date/index.d.ts +147 -551
  27. package/lib/Date/index.d.ts.map +1 -1
  28. package/lib/Date/index.js +431 -693
  29. package/lib/Error/AppErrorHandler.d.ts.map +1 -1
  30. package/lib/Error/AppErrorHandler.js +7 -1
  31. package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts +11 -3
  32. package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts.map +1 -1
  33. package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.js +19 -4
  34. package/lib/util/Str.d.ts +95 -382
  35. package/lib/util/Str.d.ts.map +1 -1
  36. package/lib/util/Str.js +402 -542
  37. package/package.json +1 -1
@@ -5,36 +5,115 @@ const Application_1 = require("../lib/Application/Application");
5
5
  const ApplicationBuilder_1 = require("../lib/Application/ApplicationBuilder");
6
6
  (0, vitest_1.describe)("ApplicationBuilder", () => {
7
7
  let app;
8
+ let builder;
8
9
  (0, vitest_1.beforeEach)(() => {
9
10
  app = Application_1.Application.getInstance();
11
+ builder = new ApplicationBuilder_1.ApplicationBuilder(app);
10
12
  });
11
- (0, vitest_1.it)("withConfig merges config without queue when queue is missing", () => {
12
- const config = { custom: "value" };
13
- const builder = new ApplicationBuilder_1.ApplicationBuilder(app);
14
- (0, vitest_1.expect)(() => builder.withConfig(config)).not.toThrow();
15
- (0, vitest_1.expect)(app.config).toMatchObject({ custom: "value" });
16
- (0, vitest_1.expect)(app.has("Queue")).toBe(false);
17
- });
18
- (0, vitest_1.it)("withConfig stores queue config without registering Queue (QueueServiceProvider handles that)", () => {
19
- const config = {
20
- queue: {
13
+ // ── withConfig ──────────────────────────────────────────────────────────────
14
+ (0, vitest_1.describe)("withConfig", () => {
15
+ (0, vitest_1.it)("merges plain config into app.config", () => {
16
+ builder.withConfig({ custom: "value" });
17
+ (0, vitest_1.expect)(app.config).toMatchObject({ custom: "value" });
18
+ });
19
+ (0, vitest_1.it)("does not register Queue binding (that is QueueServiceProvider's job)", () => {
20
+ builder.withConfig({ queue: { default: "memory", connections: {} } });
21
+ (0, vitest_1.expect)(app.has("Queue")).toBe(false);
22
+ });
23
+ (0, vitest_1.it)("stores queue config on app.config", () => {
24
+ const queueCfg = {
21
25
  default: "memory",
22
- connections: {
23
- memory: { driver: "memory", queue: "default" },
24
- },
25
- },
26
- };
27
- const builder = new ApplicationBuilder_1.ApplicationBuilder(app);
28
- builder.withConfig(config);
29
- (0, vitest_1.expect)(app.config.queue).toMatchObject(config.queue);
30
- (0, vitest_1.expect)(app.has("Queue")).toBe(false);
26
+ connections: { memory: { driver: "memory", queue: "default" } },
27
+ };
28
+ builder.withConfig({ queue: queueCfg });
29
+ (0, vitest_1.expect)(app.config.queue).toMatchObject(queueCfg);
30
+ });
31
+ (0, vitest_1.it)("merges multiple calls additively", () => {
32
+ builder.withConfig({ a: 1 });
33
+ builder.withConfig({ b: 2 });
34
+ (0, vitest_1.expect)(app.config).toMatchObject({ a: 1, b: 2 });
35
+ });
36
+ (0, vitest_1.it)("later call overwrites duplicate keys", () => {
37
+ builder.withConfig({ key: "first" });
38
+ builder.withConfig({ key: "second" });
39
+ (0, vitest_1.expect)(app.config.key).toBe("second");
40
+ });
41
+ (0, vitest_1.it)("returns the builder for chaining", () => {
42
+ const result = builder.withConfig({});
43
+ (0, vitest_1.expect)(result).toBe(builder);
44
+ });
45
+ });
46
+ // ── withRouting ─────────────────────────────────────────────────────────────
47
+ (0, vitest_1.describe)("withRouting", () => {
48
+ (0, vitest_1.it)("stores routes with rootPath prepended to name", () => {
49
+ builder.withRouting([{ name: "route/api", prefix: "/api" }]);
50
+ (0, vitest_1.expect)(app.configRoutes).toHaveLength(1);
51
+ (0, vitest_1.expect)(app.configRoutes[0].name).toContain("route/api");
52
+ (0, vitest_1.expect)(app.configRoutes[0].prefix).toBe("/api");
53
+ });
54
+ (0, vitest_1.it)("accepts multiple routes", () => {
55
+ builder.withRouting([
56
+ { name: "route/web", prefix: "/" },
57
+ { name: "route/api", prefix: "/api" },
58
+ ]);
59
+ (0, vitest_1.expect)(app.configRoutes).toHaveLength(2);
60
+ });
61
+ (0, vitest_1.it)("empty route list stores an empty array", () => {
62
+ builder.withRouting([]);
63
+ (0, vitest_1.expect)(app.configRoutes).toEqual([]);
64
+ });
65
+ (0, vitest_1.it)("returns the builder for chaining", () => {
66
+ const result = builder.withRouting([]);
67
+ (0, vitest_1.expect)(result).toBe(builder);
68
+ });
69
+ });
70
+ // ── withKernel ──────────────────────────────────────────────────────────────
71
+ (0, vitest_1.describe)("withKernel", () => {
72
+ (0, vitest_1.it)("binds the kernel class as HttpKernel", () => {
73
+ class FakeKernel {
74
+ constructor() {
75
+ this.middlewares = [];
76
+ }
77
+ }
78
+ builder.withKernel(FakeKernel);
79
+ (0, vitest_1.expect)(app.has("HttpKernel")).toBe(true);
80
+ });
81
+ (0, vitest_1.it)("resolves to the provided kernel class", () => {
82
+ class FakeKernel {
83
+ constructor() {
84
+ this.middlewares = [];
85
+ }
86
+ }
87
+ builder.withKernel(FakeKernel);
88
+ const resolved = app.resolve("HttpKernel");
89
+ (0, vitest_1.expect)(resolved).toBeInstanceOf(FakeKernel);
90
+ });
91
+ (0, vitest_1.it)("returns the builder for chaining", () => {
92
+ class FakeKernel {
93
+ constructor() {
94
+ this.middlewares = [];
95
+ }
96
+ }
97
+ const result = builder.withKernel(FakeKernel);
98
+ (0, vitest_1.expect)(result).toBe(builder);
99
+ });
100
+ });
101
+ // ── withConsole ─────────────────────────────────────────────────────────────
102
+ (0, vitest_1.describe)("withConsole", () => {
103
+ (0, vitest_1.it)("binds ConsoleKernel into the container", () => {
104
+ builder.withConsole();
105
+ (0, vitest_1.expect)(app.has("ConsoleKernel")).toBe(true);
106
+ });
107
+ (0, vitest_1.it)("returns the builder for chaining", () => {
108
+ const result = builder.withConsole();
109
+ (0, vitest_1.expect)(result).toBe(builder);
110
+ });
31
111
  });
32
- (0, vitest_1.it)("withRouting maps route config with rootPath", () => {
33
- const builder = new ApplicationBuilder_1.ApplicationBuilder(app);
34
- const routes = [{ name: "route/api", prefix: "/api" }];
35
- builder.withRouting(routes);
36
- (0, vitest_1.expect)(app.configRoutes).toHaveLength(1);
37
- (0, vitest_1.expect)(app.configRoutes[0].name).toContain("route/api");
38
- (0, vitest_1.expect)(app.configRoutes[0].prefix).toBe("/api");
112
+ // ── create ──────────────────────────────────────────────────────────────────
113
+ (0, vitest_1.describe)("create", () => {
114
+ (0, vitest_1.it)("returns the application instance", () => {
115
+ const result = builder.create();
116
+ (0, vitest_1.expect)(result).toBe(app);
117
+ });
39
118
  });
40
119
  });
@@ -2,70 +2,210 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
4
  const Application_1 = require("../lib/Application/Application");
5
- /**
6
- * Tests Container behavior via Application (extends ExpressApplication extends Container).
7
- */
8
5
  (0, vitest_1.describe)("Container", () => {
9
6
  let container;
10
7
  (0, vitest_1.beforeEach)(() => {
11
8
  container = Application_1.Application.getInstance();
12
9
  });
13
- (0, vitest_1.it)("binds and resolves a value via factory", () => {
14
- container.bind("Foo", () => "bar");
15
- (0, vitest_1.expect)(container.resolve("Foo")).toBe("bar");
10
+ // ── bind / resolve ──────────────────────────────────────────────────────────
11
+ (0, vitest_1.describe)("bind / resolve", () => {
12
+ (0, vitest_1.it)("binds a factory and resolves its return value", () => {
13
+ container.bind("Foo", () => "bar");
14
+ (0, vitest_1.expect)(container.resolve("Foo")).toBe("bar");
15
+ });
16
+ (0, vitest_1.it)("shared bind returns same instance on repeated resolves", () => {
17
+ class Service {
18
+ }
19
+ container.bind("SharedSvc", Service, true);
20
+ const a = container.resolve("SharedSvc");
21
+ const b = container.resolve("SharedSvc");
22
+ (0, vitest_1.expect)(a).toBeInstanceOf(Service);
23
+ (0, vitest_1.expect)(a).toBe(b);
24
+ });
25
+ (0, vitest_1.it)("non-shared bind returns a new instance on each resolve", () => {
26
+ class Disposable {
27
+ }
28
+ container.bind("Disposable", Disposable, false);
29
+ const a = container.resolve("Disposable");
30
+ const b = container.resolve("Disposable");
31
+ (0, vitest_1.expect)(a).not.toBe(b);
32
+ });
33
+ (0, vitest_1.it)("resolve throws for unregistered abstract", () => {
34
+ (0, vitest_1.expect)(() => container.resolve("__never_registered__")).toThrow(/No binding registered/);
35
+ });
36
+ (0, vitest_1.it)("binds a factory function and resolves its return value each call", () => {
37
+ let n = 0;
38
+ container.bind("Counter", () => ++n);
39
+ (0, vitest_1.expect)(container.resolve("Counter")).toBe(1);
40
+ (0, vitest_1.expect)(container.resolve("Counter")).toBe(2);
41
+ });
16
42
  });
17
- (0, vitest_1.it)("binds a class and resolves instance", () => {
18
- class Service {
19
- }
20
- container.bind("Service", Service, true);
21
- const a = container.resolve("Service");
22
- const b = container.resolve("Service");
23
- (0, vitest_1.expect)(a).toBeInstanceOf(Service);
24
- (0, vitest_1.expect)(a).toBe(b); // shared
43
+ // ── singleton ───────────────────────────────────────────────────────────────
44
+ (0, vitest_1.describe)("singleton", () => {
45
+ (0, vitest_1.it)("returns same instance on every resolve", () => {
46
+ class Singleton {
47
+ }
48
+ container.singleton("MySingleton", Singleton);
49
+ const a = container.resolve("MySingleton");
50
+ const b = container.resolve("MySingleton");
51
+ (0, vitest_1.expect)(a).toBe(b);
52
+ });
53
+ (0, vitest_1.it)("does not re-register if already bound", () => {
54
+ class First {
55
+ }
56
+ class Second {
57
+ }
58
+ container.singleton("OnceOnly", First);
59
+ container.singleton("OnceOnly", Second); // should be ignored
60
+ const inst = container.resolve("OnceOnly");
61
+ (0, vitest_1.expect)(inst).toBeInstanceOf(First);
62
+ });
25
63
  });
26
- (0, vitest_1.it)("singleton returns same instance", () => {
27
- class Singleton {
28
- }
29
- container.singleton("Singleton", Singleton);
30
- const a = container.resolve("Singleton");
31
- const b = container.resolve("Singleton");
32
- (0, vitest_1.expect)(a).toBe(b);
64
+ // ── instance ────────────────────────────────────────────────────────────────
65
+ (0, vitest_1.describe)("instance", () => {
66
+ (0, vitest_1.it)("stores a concrete object and returns the same reference", () => {
67
+ const obj = { id: 99 };
68
+ container.instance("ConcreteObj", obj);
69
+ (0, vitest_1.expect)(container.resolve("ConcreteObj")).toBe(obj);
70
+ });
71
+ (0, vitest_1.it)("instance also populates aliased key if alias was registered first", () => {
72
+ const obj = { val: "shared" };
73
+ container.alias("AliasTarget", "AliasKey");
74
+ container.instance("AliasTarget", obj);
75
+ (0, vitest_1.expect)(container.resolve("AliasKey")).toBe(obj);
76
+ });
33
77
  });
34
- (0, vitest_1.it)("instance sets concrete instance", () => {
35
- const obj = { id: 1 };
36
- container.instance("Obj", obj);
37
- (0, vitest_1.expect)(container.resolve("Obj")).toBe(obj);
78
+ // ── alias ───────────────────────────────────────────────────────────────────
79
+ (0, vitest_1.describe)("alias", () => {
80
+ (0, vitest_1.it)("resolves via alias to original binding", () => {
81
+ container.bind("OrigSvc", () => "from-orig");
82
+ container.alias("OrigSvc", "Aliased");
83
+ (0, vitest_1.expect)(container.resolve("Aliased")).toBe("from-orig");
84
+ });
38
85
  });
39
- (0, vitest_1.it)("alias resolves to original binding", () => {
40
- container.bind("Original", () => "value");
41
- container.alias("Original", "Alias");
42
- (0, vitest_1.expect)(container.resolve("Alias")).toBe("value");
86
+ // ── has ─────────────────────────────────────────────────────────────────────
87
+ (0, vitest_1.describe)("has", () => {
88
+ (0, vitest_1.it)("returns true for a bound abstract", () => {
89
+ container.bind("BoundKey", () => null);
90
+ (0, vitest_1.expect)(container.has("BoundKey")).toBe(true);
91
+ });
92
+ (0, vitest_1.it)("returns true for an instance", () => {
93
+ container.instance("InstKey", {});
94
+ (0, vitest_1.expect)(container.has("InstKey")).toBe(true);
95
+ });
96
+ (0, vitest_1.it)("returns true for an alias", () => {
97
+ container.bind("RealKey", () => null);
98
+ container.alias("RealKey", "AliasForHas");
99
+ (0, vitest_1.expect)(container.has("AliasForHas")).toBe(true);
100
+ });
101
+ (0, vitest_1.it)("returns false for an unknown key", () => {
102
+ (0, vitest_1.expect)(container.has("__not_there__")).toBe(false);
103
+ });
43
104
  });
44
- (0, vitest_1.it)("has returns true for registered bindings", () => {
45
- container.bind("X", "y");
46
- (0, vitest_1.expect)(container.has("X")).toBe(true);
47
- (0, vitest_1.expect)(container.has("Unknown")).toBe(false);
105
+ // ── forget ──────────────────────────────────────────────────────────────────
106
+ (0, vitest_1.describe)("forget", () => {
107
+ (0, vitest_1.it)("removes a singleton instance so the next resolve creates a fresh one", () => {
108
+ class Temp {
109
+ }
110
+ container.singleton("TempSvc", Temp);
111
+ const a = container.resolve("TempSvc");
112
+ container.forget("TempSvc");
113
+ const b = container.resolve("TempSvc");
114
+ (0, vitest_1.expect)(a).not.toBe(b);
115
+ });
116
+ (0, vitest_1.it)("removes the aliased instance as well", () => {
117
+ class TZ {
118
+ }
119
+ container.singleton("TZBase", TZ);
120
+ container.alias("TZBase", "TZAlias");
121
+ container.resolve("TZBase"); // cache it
122
+ container.forget("TZBase"); // should also clear aliased cache
123
+ // after forget the binding is still there, so resolve works but returns new instance
124
+ (0, vitest_1.expect)(() => container.resolve("TZBase")).not.toThrow();
125
+ });
48
126
  });
49
- (0, vitest_1.it)("forget removes instance", () => {
50
- class Temp {
51
- }
52
- container.singleton("Temp", Temp);
53
- const a = container.resolve("Temp");
54
- container.forget("Temp");
55
- const b = container.resolve("Temp");
56
- (0, vitest_1.expect)(a).not.toBe(b);
127
+ // ── forgetMany ──────────────────────────────────────────────────────────────
128
+ (0, vitest_1.describe)("forgetMany", () => {
129
+ (0, vitest_1.it)("removes all listed instances", () => {
130
+ class A {
131
+ }
132
+ class B {
133
+ }
134
+ container.singleton("AA", A);
135
+ container.singleton("BB", B);
136
+ const a1 = container.resolve("AA");
137
+ const b1 = container.resolve("BB");
138
+ container.forgetMany(["AA", "BB"]);
139
+ const a2 = container.resolve("AA");
140
+ const b2 = container.resolve("BB");
141
+ (0, vitest_1.expect)(a1).not.toBe(a2);
142
+ (0, vitest_1.expect)(b1).not.toBe(b2);
143
+ });
144
+ (0, vitest_1.it)("is a no-op for unknown keys", () => {
145
+ (0, vitest_1.expect)(() => container.forgetMany(["__x__", "__y__"])).not.toThrow();
146
+ });
57
147
  });
58
- (0, vitest_1.it)("make instantiates class with auto-binding", () => {
59
- class MyService {
60
- constructor() {
61
- this.name = "test";
148
+ // ── make ────────────────────────────────────────────────────────────────────
149
+ (0, vitest_1.describe)("make", () => {
150
+ (0, vitest_1.it)("instantiates a class without prior binding", () => {
151
+ class Widget {
152
+ constructor() {
153
+ this.name = "widget";
154
+ }
155
+ }
156
+ const inst = container.make(Widget);
157
+ (0, vitest_1.expect)(inst).toBeInstanceOf(Widget);
158
+ (0, vitest_1.expect)(inst?.name).toBe("widget");
159
+ });
160
+ (0, vitest_1.it)("passes explicit constructor arguments", () => {
161
+ class Greeter {
162
+ constructor(greeting) {
163
+ this.greeting = greeting;
164
+ }
62
165
  }
63
- }
64
- const instance = container.make(MyService);
65
- (0, vitest_1.expect)(instance).toBeInstanceOf(MyService);
66
- (0, vitest_1.expect)(instance?.name).toBe("test");
166
+ const inst = container.make(Greeter, ["hello"]);
167
+ (0, vitest_1.expect)(inst?.greeting).toBe("hello");
168
+ });
67
169
  });
68
- (0, vitest_1.it)("resolve throws for unregistered binding", () => {
69
- (0, vitest_1.expect)(() => container.resolve("NonExistent")).toThrow(/No binding registered/);
170
+ // ── build ───────────────────────────────────────────────────────────────────
171
+ (0, vitest_1.describe)("build", () => {
172
+ (0, vitest_1.it)("builds a class with no dependencies", () => {
173
+ class Plain {
174
+ }
175
+ const inst = container.build(Plain);
176
+ (0, vitest_1.expect)(inst).toBeInstanceOf(Plain);
177
+ });
178
+ (0, vitest_1.it)("builds a class passing explicit params", () => {
179
+ class Parameterised {
180
+ constructor(x) {
181
+ this.x = x;
182
+ }
183
+ }
184
+ const inst = container.build(Parameterised, [42]);
185
+ (0, vitest_1.expect)(inst.x).toBe(42);
186
+ });
187
+ (0, vitest_1.it)("calls a factory function if given one", () => {
188
+ const factory = () => ({ built: true });
189
+ const result = container.build(factory);
190
+ (0, vitest_1.expect)(result.built).toBe(true);
191
+ });
192
+ });
193
+ // ── callMethod ──────────────────────────────────────────────────────────────
194
+ (0, vitest_1.describe)("callMethod", () => {
195
+ (0, vitest_1.it)("calls a plain method (no @Inject metadata) with provided args", () => {
196
+ class Calculator {
197
+ add(a, b) {
198
+ return a + b;
199
+ }
200
+ }
201
+ const calc = new Calculator();
202
+ const result = container.callMethod(calc, "add", 3, 4);
203
+ (0, vitest_1.expect)(result).toBe(7);
204
+ });
205
+ (0, vitest_1.it)("throws an AppError when the method does not exist", () => {
206
+ class Empty {
207
+ }
208
+ (0, vitest_1.expect)(() => container.callMethod(new Empty(), "nonExistent")).toThrow();
209
+ });
70
210
  });
71
211
  });
@@ -188,3 +188,73 @@ class NestedFolderJob extends Job_1.Job {
188
188
  spy.mockRestore();
189
189
  });
190
190
  });
191
+ // ── Queue additional methods ──────────────────────────────────────────────────
192
+ (0, vitest_1.describe)("Queue additional methods", () => {
193
+ let queue;
194
+ let app;
195
+ let originalApp;
196
+ (0, vitest_1.beforeEach)(() => {
197
+ app = Application_1.Application.getInstance();
198
+ originalApp = globalThis.app;
199
+ globalThis.app = app;
200
+ queue = new Queue_1.Queue({ driver: "memory", queue: "default" });
201
+ app.instance("Queue", queue);
202
+ });
203
+ (0, vitest_1.afterEach)(() => {
204
+ globalThis.app = originalApp;
205
+ });
206
+ (0, vitest_1.describe)("registerJob", () => {
207
+ (0, vitest_1.it)("registers a job class so processNext can resolve it", async () => {
208
+ queue.registerJob("TestJob", TestJob);
209
+ const job = new TestJob({ value: "registered" });
210
+ await queue.push(job);
211
+ const result = await queue.processNext();
212
+ (0, vitest_1.expect)(result).toBe(true);
213
+ });
214
+ });
215
+ (0, vitest_1.describe)("getQueues", () => {
216
+ (0, vitest_1.it)("returns an array (empty when no jobs are queued)", async () => {
217
+ const queues = await queue.getQueues();
218
+ (0, vitest_1.expect)(Array.isArray(queues)).toBe(true);
219
+ });
220
+ (0, vitest_1.it)("returns records after a job is pushed", async () => {
221
+ const job = new TestJob({ value: "q-test" });
222
+ await queue.push(job);
223
+ const queues = await queue.getQueues();
224
+ (0, vitest_1.expect)(queues.length).toBeGreaterThan(0);
225
+ });
226
+ });
227
+ (0, vitest_1.describe)("findQueueById", () => {
228
+ (0, vitest_1.it)("returns the job record for a known id", async () => {
229
+ const job = new TestJob({ value: "find-me" });
230
+ const id = await queue.push(job);
231
+ const record = await queue.findQueueById(id);
232
+ (0, vitest_1.expect)(record).toBeDefined();
233
+ });
234
+ (0, vitest_1.it)("returns undefined/null for an unknown id", async () => {
235
+ const record = await queue.findQueueById("non-existent-id");
236
+ (0, vitest_1.expect)(record == null).toBe(true);
237
+ });
238
+ });
239
+ (0, vitest_1.describe)("findQueueBy", () => {
240
+ (0, vitest_1.it)("finds jobs by queue name", async () => {
241
+ const job = new TestJob({ value: "by-queue" });
242
+ await queue.push(job);
243
+ const results = await queue.findQueueBy("queue", "default");
244
+ (0, vitest_1.expect)(Array.isArray(results)).toBe(true);
245
+ (0, vitest_1.expect)(results.length).toBeGreaterThan(0);
246
+ });
247
+ });
248
+ (0, vitest_1.describe)("deleteJob", () => {
249
+ (0, vitest_1.it)("removes a job so it is no longer found", async () => {
250
+ const job = new TestJob({ value: "delete-me" });
251
+ const id = await queue.push(job);
252
+ await queue.deleteJob(id);
253
+ const record = await queue.findQueueById(id);
254
+ (0, vitest_1.expect)(record == null).toBe(true);
255
+ });
256
+ (0, vitest_1.it)("does not throw when deleting an unknown id", async () => {
257
+ await (0, vitest_1.expect)(queue.deleteJob("ghost-id")).resolves.not.toThrow();
258
+ });
259
+ });
260
+ });