@devisfuture/electron-modular 1.1.9 → 1.1.10

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 (45) hide show
  1. package/dist/@core/__tests__/container.test.d.ts +1 -0
  2. package/dist/@core/__tests__/container.test.js +409 -0
  3. package/dist/@core/bootstrap/__tests__/bootstrap.test.d.ts +1 -0
  4. package/dist/@core/bootstrap/__tests__/bootstrap.test.js +131 -0
  5. package/dist/@core/bootstrap/__tests__/initialize-module.test.d.ts +1 -0
  6. package/dist/@core/bootstrap/__tests__/initialize-module.test.js +140 -0
  7. package/dist/@core/bootstrap/__tests__/instantiate-module.test.d.ts +1 -0
  8. package/dist/@core/bootstrap/__tests__/instantiate-module.test.js +174 -0
  9. package/dist/@core/bootstrap/__tests__/register-imports.test.d.ts +1 -0
  10. package/dist/@core/bootstrap/__tests__/register-imports.test.js +112 -0
  11. package/dist/@core/bootstrap/__tests__/register-ipc-handlers.test.d.ts +1 -0
  12. package/dist/@core/bootstrap/__tests__/register-ipc-handlers.test.js +68 -0
  13. package/dist/@core/bootstrap/__tests__/register-providers.test.d.ts +1 -0
  14. package/dist/@core/bootstrap/__tests__/register-providers.test.js +132 -0
  15. package/dist/@core/bootstrap/__tests__/register-windows.test.d.ts +1 -0
  16. package/dist/@core/bootstrap/__tests__/register-windows.test.js +109 -0
  17. package/dist/@core/bootstrap/__tests__/settings.test.d.ts +1 -0
  18. package/dist/@core/bootstrap/__tests__/settings.test.js +141 -0
  19. package/dist/@core/control-window/__tests__/cache.test.d.ts +1 -0
  20. package/dist/@core/control-window/__tests__/cache.test.js +50 -0
  21. package/dist/@core/control-window/__tests__/destroy.test.d.ts +1 -0
  22. package/dist/@core/control-window/__tests__/destroy.test.js +69 -0
  23. package/dist/@core/control-window/__tests__/receive.test.d.ts +1 -0
  24. package/dist/@core/control-window/__tests__/receive.test.js +68 -0
  25. package/dist/@core/decorators/__tests__/inject.test.d.ts +1 -0
  26. package/dist/@core/decorators/__tests__/inject.test.js +174 -0
  27. package/dist/@core/decorators/__tests__/injectable.test.d.ts +1 -0
  28. package/dist/@core/decorators/__tests__/injectable.test.js +73 -0
  29. package/dist/@core/decorators/__tests__/ipc-handler.test.d.ts +1 -0
  30. package/dist/@core/decorators/__tests__/ipc-handler.test.js +72 -0
  31. package/dist/@core/decorators/__tests__/rg-module.test.d.ts +1 -0
  32. package/dist/@core/decorators/__tests__/rg-module.test.js +135 -0
  33. package/dist/@core/decorators/__tests__/window-manager.test.d.ts +1 -0
  34. package/dist/@core/decorators/__tests__/window-manager.test.js +110 -0
  35. package/dist/@core/errors/__tests__/index.test.d.ts +1 -0
  36. package/dist/@core/errors/__tests__/index.test.js +82 -0
  37. package/dist/@core/utils/__tests__/dependency-tokens.test.d.ts +1 -0
  38. package/dist/@core/utils/__tests__/dependency-tokens.test.js +186 -0
  39. package/dist/__mocks__/electron.d.ts +88 -0
  40. package/dist/__mocks__/electron.js +76 -0
  41. package/dist/__tests__/config.test.d.ts +1 -0
  42. package/dist/__tests__/config.test.js +24 -0
  43. package/dist/__tests__/setup.d.ts +1 -0
  44. package/dist/__tests__/setup.js +9 -0
  45. package/package.json +6 -2
@@ -0,0 +1,135 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { describe, it, expect } from "vitest";
8
+ import { RgModule } from "../rg-module.js";
9
+ import "reflect-metadata/lite";
10
+ describe("RgModule decorator", () => {
11
+ it("should store module metadata", () => {
12
+ const metadata = {
13
+ providers: [],
14
+ exports: [],
15
+ };
16
+ let TestModule = class TestModule {
17
+ };
18
+ TestModule = __decorate([
19
+ RgModule(metadata)
20
+ ], TestModule);
21
+ const storedMetadata = Reflect.getMetadata("RgModule", TestModule);
22
+ expect(storedMetadata).toEqual(metadata);
23
+ });
24
+ it("should store imports", () => {
25
+ class ImportedModule {
26
+ }
27
+ let TestModule = class TestModule {
28
+ };
29
+ TestModule = __decorate([
30
+ RgModule({
31
+ imports: [ImportedModule],
32
+ })
33
+ ], TestModule);
34
+ const metadata = Reflect.getMetadata("RgModule", TestModule);
35
+ expect(metadata.imports).toEqual([ImportedModule]);
36
+ });
37
+ it("should store providers", () => {
38
+ class ServiceA {
39
+ }
40
+ class ServiceB {
41
+ }
42
+ let TestModule = class TestModule {
43
+ };
44
+ TestModule = __decorate([
45
+ RgModule({
46
+ providers: [ServiceA, ServiceB],
47
+ })
48
+ ], TestModule);
49
+ const metadata = Reflect.getMetadata("RgModule", TestModule);
50
+ expect(metadata.providers).toEqual([ServiceA, ServiceB]);
51
+ });
52
+ it("should store exports", () => {
53
+ const TOKEN1 = Symbol("token1");
54
+ const TOKEN2 = "token2";
55
+ let TestModule = class TestModule {
56
+ };
57
+ TestModule = __decorate([
58
+ RgModule({
59
+ exports: [TOKEN1, TOKEN2],
60
+ })
61
+ ], TestModule);
62
+ const metadata = Reflect.getMetadata("RgModule", TestModule);
63
+ expect(metadata.exports).toEqual([TOKEN1, TOKEN2]);
64
+ });
65
+ it("should store IPC handlers", () => {
66
+ class Handler1 {
67
+ onInit(data) { }
68
+ }
69
+ class Handler2 {
70
+ onInit(data) { }
71
+ }
72
+ let TestModule = class TestModule {
73
+ };
74
+ TestModule = __decorate([
75
+ RgModule({
76
+ ipc: [Handler1, Handler2],
77
+ })
78
+ ], TestModule);
79
+ const metadata = Reflect.getMetadata("RgModule", TestModule);
80
+ expect(metadata.ipc).toEqual([Handler1, Handler2]);
81
+ });
82
+ it("should store windows", () => {
83
+ class Window1 {
84
+ }
85
+ class Window2 {
86
+ }
87
+ let TestModule = class TestModule {
88
+ };
89
+ TestModule = __decorate([
90
+ RgModule({
91
+ windows: [Window1, Window2],
92
+ })
93
+ ], TestModule);
94
+ const metadata = Reflect.getMetadata("RgModule", TestModule);
95
+ expect(metadata.windows).toEqual([Window1, Window2]);
96
+ });
97
+ it("should handle empty metadata", () => {
98
+ let TestModule = class TestModule {
99
+ };
100
+ TestModule = __decorate([
101
+ RgModule({})
102
+ ], TestModule);
103
+ const metadata = Reflect.getMetadata("RgModule", TestModule);
104
+ expect(metadata).toEqual({});
105
+ });
106
+ it("should work with complete metadata", () => {
107
+ class ImportModule {
108
+ }
109
+ class Provider1 {
110
+ }
111
+ class Handler1 {
112
+ onInit(data) { }
113
+ }
114
+ class Window1 {
115
+ }
116
+ const EXPORT_TOKEN = Symbol("export");
117
+ let CompleteModule = class CompleteModule {
118
+ };
119
+ CompleteModule = __decorate([
120
+ RgModule({
121
+ imports: [ImportModule],
122
+ providers: [Provider1],
123
+ ipc: [Handler1],
124
+ windows: [Window1],
125
+ exports: [EXPORT_TOKEN],
126
+ })
127
+ ], CompleteModule);
128
+ const metadata = Reflect.getMetadata("RgModule", CompleteModule);
129
+ expect(metadata.imports).toEqual([ImportModule]);
130
+ expect(metadata.providers).toEqual([Provider1]);
131
+ expect(metadata.ipc).toEqual([Handler1]);
132
+ expect(metadata.windows).toEqual([Window1]);
133
+ expect(metadata.exports).toEqual([EXPORT_TOKEN]);
134
+ });
135
+ });
@@ -0,0 +1 @@
1
+ import "reflect-metadata/lite";
@@ -0,0 +1,110 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { describe, it, expect } from "vitest";
8
+ import { WindowManager } from "../window-manager.js";
9
+ import "reflect-metadata/lite";
10
+ describe("WindowManager decorator", () => {
11
+ it("should store window creation options", () => {
12
+ const options = {
13
+ name: "main",
14
+ options: {
15
+ width: 800,
16
+ height: 600,
17
+ },
18
+ };
19
+ let MainWindow = class MainWindow {
20
+ };
21
+ MainWindow = __decorate([
22
+ WindowManager(options)
23
+ ], MainWindow);
24
+ const metadata = Reflect.getMetadata("WindowManager", MainWindow);
25
+ expect(metadata).toEqual(options);
26
+ });
27
+ it("should store window with custom name", () => {
28
+ const options = {
29
+ name: "settings",
30
+ options: {
31
+ width: 600,
32
+ height: 400,
33
+ },
34
+ };
35
+ let SettingsWindow = class SettingsWindow {
36
+ };
37
+ SettingsWindow = __decorate([
38
+ WindowManager(options)
39
+ ], SettingsWindow);
40
+ const metadata = Reflect.getMetadata("WindowManager", SettingsWindow);
41
+ expect(metadata.name).toBe("settings");
42
+ });
43
+ it("should store complete BrowserWindow options", () => {
44
+ const options = {
45
+ name: "main",
46
+ options: {
47
+ width: 1024,
48
+ height: 768,
49
+ webPreferences: {
50
+ nodeIntegration: false,
51
+ contextIsolation: true,
52
+ },
53
+ title: "Test Window",
54
+ },
55
+ };
56
+ let TestWindow = class TestWindow {
57
+ };
58
+ TestWindow = __decorate([
59
+ WindowManager(options)
60
+ ], TestWindow);
61
+ const metadata = Reflect.getMetadata("WindowManager", TestWindow);
62
+ expect(metadata.options.width).toBe(1024);
63
+ expect(metadata.options.height).toBe(768);
64
+ expect(metadata.options.webPreferences).toEqual({
65
+ nodeIntegration: false,
66
+ contextIsolation: true,
67
+ });
68
+ });
69
+ it("should work with minimal options", () => {
70
+ const options = {
71
+ name: "minimal",
72
+ options: {},
73
+ };
74
+ let MinimalWindow = class MinimalWindow {
75
+ };
76
+ MinimalWindow = __decorate([
77
+ WindowManager(options)
78
+ ], MinimalWindow);
79
+ const metadata = Reflect.getMetadata("WindowManager", MinimalWindow);
80
+ expect(metadata).toEqual(options);
81
+ });
82
+ it("should not affect non-decorated classes", () => {
83
+ class NonDecoratedWindow {
84
+ }
85
+ const metadata = Reflect.getMetadata("WindowManager", NonDecoratedWindow);
86
+ expect(metadata).toBeUndefined();
87
+ });
88
+ it("should work with multiple window managers", () => {
89
+ const mainOptions = {
90
+ name: "main",
91
+ options: { width: 800 },
92
+ };
93
+ const settingsOptions = {
94
+ name: "settings",
95
+ options: { width: 600 },
96
+ };
97
+ let MainWindow = class MainWindow {
98
+ };
99
+ MainWindow = __decorate([
100
+ WindowManager(mainOptions)
101
+ ], MainWindow);
102
+ let SettingsWindow = class SettingsWindow {
103
+ };
104
+ SettingsWindow = __decorate([
105
+ WindowManager(settingsOptions)
106
+ ], SettingsWindow);
107
+ expect(Reflect.getMetadata("WindowManager", MainWindow)).toEqual(mainOptions);
108
+ expect(Reflect.getMetadata("WindowManager", SettingsWindow)).toEqual(settingsOptions);
109
+ });
110
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,82 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { ModuleNotRegisteredError, ProviderNotFoundError, ModuleDecoratorMissingError, InvalidProviderError, SettingsNotInitializedError, } from "../index.js";
3
+ describe("Error classes", () => {
4
+ describe("ModuleNotRegisteredError", () => {
5
+ it("should create error with correct message", () => {
6
+ const error = new ModuleNotRegisteredError("TestModule");
7
+ expect(error.message).toBe('Module "TestModule" is not registered in the container.');
8
+ expect(error.name).toBe("ModuleNotRegisteredError");
9
+ });
10
+ it("should be instanceof Error", () => {
11
+ const error = new ModuleNotRegisteredError("TestModule");
12
+ expect(error).toBeInstanceOf(Error);
13
+ });
14
+ it("should be instanceof ModuleNotRegisteredError", () => {
15
+ const error = new ModuleNotRegisteredError("TestModule");
16
+ expect(error).toBeInstanceOf(ModuleNotRegisteredError);
17
+ });
18
+ });
19
+ describe("ProviderNotFoundError", () => {
20
+ it("should create error with correct message", () => {
21
+ const error = new ProviderNotFoundError("MyToken", "MyModule");
22
+ expect(error.message).toBe('Provider not found for token "MyToken" in module "MyModule" or its imports.');
23
+ expect(error.name).toBe("ProviderNotFoundError");
24
+ });
25
+ it("should be instanceof Error", () => {
26
+ const error = new ProviderNotFoundError("token", "module");
27
+ expect(error).toBeInstanceOf(Error);
28
+ });
29
+ it("should handle symbol tokens", () => {
30
+ const error = new ProviderNotFoundError("Symbol(test)", "TestModule");
31
+ expect(error.message).toContain("Symbol(test)");
32
+ });
33
+ });
34
+ describe("ModuleDecoratorMissingError", () => {
35
+ it("should create error with correct message", () => {
36
+ const error = new ModuleDecoratorMissingError("TestModule");
37
+ expect(error.message).toBe("Module TestModule does not have the @RgModule decorator");
38
+ expect(error.name).toBe("ModuleDecoratorMissingError");
39
+ });
40
+ it("should be instanceof Error", () => {
41
+ const error = new ModuleDecoratorMissingError("TestModule");
42
+ expect(error).toBeInstanceOf(Error);
43
+ });
44
+ });
45
+ describe("InvalidProviderError", () => {
46
+ it("should create error with correct message", () => {
47
+ const error = new InvalidProviderError("TestModule");
48
+ expect(error.message).toBe("Invalid provider definition registered in module TestModule");
49
+ expect(error.name).toBe("InvalidProviderError");
50
+ });
51
+ it("should be instanceof Error", () => {
52
+ const error = new InvalidProviderError("TestModule");
53
+ expect(error).toBeInstanceOf(Error);
54
+ });
55
+ });
56
+ describe("SettingsNotInitializedError", () => {
57
+ it("should create error with correct message", () => {
58
+ const error = new SettingsNotInitializedError();
59
+ expect(error.message).toBe("App settings cache has not been initialized.");
60
+ expect(error.name).toBe("SettingsNotInitializedError");
61
+ });
62
+ it("should be instanceof Error", () => {
63
+ const error = new SettingsNotInitializedError();
64
+ expect(error).toBeInstanceOf(Error);
65
+ });
66
+ it("should not require any parameters", () => {
67
+ expect(() => new SettingsNotInitializedError()).not.toThrow();
68
+ });
69
+ });
70
+ describe("Error throwing behavior", () => {
71
+ it("should be catchable", () => {
72
+ expect(() => {
73
+ throw new ModuleNotRegisteredError("Test");
74
+ }).toThrow(ModuleNotRegisteredError);
75
+ });
76
+ it("should preserve stack trace", () => {
77
+ const error = new ProviderNotFoundError("token", "module");
78
+ expect(error.stack).toBeDefined();
79
+ expect(error.stack).toContain("ProviderNotFoundError");
80
+ });
81
+ });
82
+ });
@@ -0,0 +1 @@
1
+ import "reflect-metadata/lite";
@@ -0,0 +1,186 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { describe, it, expect, beforeEach, vi } from "vitest";
14
+ import { getDependencyTokens } from "../dependency-tokens.js";
15
+ import { Inject } from "../../decorators/inject.js";
16
+ import "reflect-metadata/lite";
17
+ describe("getDependencyTokens", () => {
18
+ beforeEach(() => {
19
+ vi.clearAllMocks();
20
+ });
21
+ it("should return empty array for class with no constructor parameters", () => {
22
+ class NoParams {
23
+ }
24
+ const tokens = getDependencyTokens(NoParams);
25
+ expect(tokens).toEqual([]);
26
+ });
27
+ it("should return design:paramtypes when available", () => {
28
+ class Dependency {
29
+ }
30
+ class ServiceWithDeps {
31
+ dep;
32
+ constructor(dep) {
33
+ this.dep = dep;
34
+ }
35
+ }
36
+ // Manually set metadata for testing since TypeScript compiler isn't running
37
+ Reflect.defineMetadata("design:paramtypes", [Dependency], ServiceWithDeps);
38
+ const tokens = getDependencyTokens(ServiceWithDeps);
39
+ expect(tokens).toHaveLength(1);
40
+ expect(tokens[0]).toBe(Dependency);
41
+ });
42
+ it("should return multiple parameter types", () => {
43
+ class Dep1 {
44
+ }
45
+ class Dep2 {
46
+ }
47
+ class Dep3 {
48
+ }
49
+ class ServiceWithMultipleDeps {
50
+ dep1;
51
+ dep2;
52
+ dep3;
53
+ constructor(dep1, dep2, dep3) {
54
+ this.dep1 = dep1;
55
+ this.dep2 = dep2;
56
+ this.dep3 = dep3;
57
+ }
58
+ }
59
+ Reflect.defineMetadata("design:paramtypes", [Dep1, Dep2, Dep3], ServiceWithMultipleDeps);
60
+ const tokens = getDependencyTokens(ServiceWithMultipleDeps);
61
+ expect(tokens).toHaveLength(3);
62
+ expect(tokens[0]).toBe(Dep1);
63
+ expect(tokens[1]).toBe(Dep2);
64
+ expect(tokens[2]).toBe(Dep3);
65
+ });
66
+ it("should override with @Inject decorator tokens", () => {
67
+ const CUSTOM_TOKEN = Symbol("custom");
68
+ class DefaultDep {
69
+ }
70
+ let ServiceWithInjectedToken = class ServiceWithInjectedToken {
71
+ dep;
72
+ constructor(dep) {
73
+ this.dep = dep;
74
+ }
75
+ };
76
+ ServiceWithInjectedToken = __decorate([
77
+ __param(0, Inject(CUSTOM_TOKEN)),
78
+ __metadata("design:paramtypes", [DefaultDep])
79
+ ], ServiceWithInjectedToken);
80
+ Reflect.defineMetadata("design:paramtypes", [DefaultDep], ServiceWithInjectedToken);
81
+ const tokens = getDependencyTokens(ServiceWithInjectedToken);
82
+ expect(tokens[0]).toBe(CUSTOM_TOKEN);
83
+ });
84
+ it("should handle mixed injected and non-injected parameters", () => {
85
+ const TOKEN1 = Symbol("token1");
86
+ const TOKEN3 = Symbol("token3");
87
+ class Dep2 {
88
+ }
89
+ let MixedService = class MixedService {
90
+ dep1;
91
+ dep2;
92
+ dep3;
93
+ constructor(dep1, dep2, dep3) {
94
+ this.dep1 = dep1;
95
+ this.dep2 = dep2;
96
+ this.dep3 = dep3;
97
+ }
98
+ };
99
+ MixedService = __decorate([
100
+ __param(0, Inject(TOKEN1)),
101
+ __param(2, Inject(TOKEN3)),
102
+ __metadata("design:paramtypes", [Object, Dep2, Object])
103
+ ], MixedService);
104
+ Reflect.defineMetadata("design:paramtypes", [Object, Dep2, Object], MixedService);
105
+ const tokens = getDependencyTokens(MixedService);
106
+ expect(tokens[0]).toBe(TOKEN1);
107
+ expect(tokens[1]).toBe(Dep2);
108
+ expect(tokens[2]).toBe(TOKEN3);
109
+ });
110
+ it("should handle string tokens from @Inject", () => {
111
+ const STRING_TOKEN = "MyStringToken";
112
+ let ServiceWithStringToken = class ServiceWithStringToken {
113
+ dep;
114
+ constructor(dep) {
115
+ this.dep = dep;
116
+ }
117
+ };
118
+ ServiceWithStringToken = __decorate([
119
+ __param(0, Inject(STRING_TOKEN)),
120
+ __metadata("design:paramtypes", [Object])
121
+ ], ServiceWithStringToken);
122
+ const tokens = getDependencyTokens(ServiceWithStringToken);
123
+ expect(tokens[0]).toBe(STRING_TOKEN);
124
+ });
125
+ it("should cache results for same constructor", () => {
126
+ class Dependency {
127
+ }
128
+ class CachedService {
129
+ dep;
130
+ constructor(dep) {
131
+ this.dep = dep;
132
+ }
133
+ }
134
+ Reflect.defineMetadata("design:paramtypes", [Dependency], CachedService);
135
+ const tokens1 = getDependencyTokens(CachedService);
136
+ const tokens2 = getDependencyTokens(CachedService);
137
+ expect(tokens1).toBe(tokens2);
138
+ });
139
+ it("should handle class with no design:paramtypes metadata", () => {
140
+ class NoMetadata {
141
+ constructor() { }
142
+ }
143
+ const tokens = getDependencyTokens(NoMetadata);
144
+ expect(tokens).toEqual([]);
145
+ });
146
+ it("should calculate maxIndex correctly when injected index exceeds paramTypes", () => {
147
+ const TOKEN = Symbol("token");
148
+ let EdgeCaseService = class EdgeCaseService {
149
+ dep;
150
+ constructor(dep) {
151
+ this.dep = dep;
152
+ }
153
+ };
154
+ EdgeCaseService = __decorate([
155
+ __param(0, Inject(TOKEN)),
156
+ __metadata("design:paramtypes", [Object])
157
+ ], EdgeCaseService);
158
+ const tokens = getDependencyTokens(EdgeCaseService);
159
+ expect(tokens.length).toBeGreaterThan(0);
160
+ expect(tokens[0]).toBe(TOKEN);
161
+ });
162
+ it("should handle multiple calls with different classes", () => {
163
+ class Dep1 {
164
+ }
165
+ class Dep2 {
166
+ }
167
+ class Service1 {
168
+ dep;
169
+ constructor(dep) {
170
+ this.dep = dep;
171
+ }
172
+ }
173
+ class Service2 {
174
+ dep;
175
+ constructor(dep) {
176
+ this.dep = dep;
177
+ }
178
+ }
179
+ Reflect.defineMetadata("design:paramtypes", [Dep1], Service1);
180
+ Reflect.defineMetadata("design:paramtypes", [Dep2], Service2);
181
+ const tokens1 = getDependencyTokens(Service1);
182
+ const tokens2 = getDependencyTokens(Service2);
183
+ expect(tokens1[0]).toBe(Dep1);
184
+ expect(tokens2[0]).toBe(Dep2);
185
+ });
186
+ });
@@ -0,0 +1,88 @@
1
+ export declare const mockApp: {
2
+ getPath: import("vitest").Mock<(name: string) => string>;
3
+ getVersion: import("vitest").Mock<() => string>;
4
+ getName: import("vitest").Mock<() => string>;
5
+ quit: import("vitest").Mock<(...args: any[]) => any>;
6
+ exit: import("vitest").Mock<(...args: any[]) => any>;
7
+ on: import("vitest").Mock<(...args: any[]) => any>;
8
+ once: import("vitest").Mock<(...args: any[]) => any>;
9
+ removeListener: import("vitest").Mock<(...args: any[]) => any>;
10
+ whenReady: import("vitest").Mock<() => Promise<void>>;
11
+ isReady: import("vitest").Mock<() => boolean>;
12
+ getAppPath: import("vitest").Mock<() => string>;
13
+ };
14
+ export declare const mockBrowserWindow: import("vitest").Mock<(...args: any[]) => any>;
15
+ export declare const mockIpcMain: {
16
+ on: import("vitest").Mock<(...args: any[]) => any>;
17
+ once: import("vitest").Mock<(...args: any[]) => any>;
18
+ handle: import("vitest").Mock<(...args: any[]) => any>;
19
+ removeHandler: import("vitest").Mock<(...args: any[]) => any>;
20
+ removeListener: import("vitest").Mock<(...args: any[]) => any>;
21
+ removeAllListeners: import("vitest").Mock<(...args: any[]) => any>;
22
+ };
23
+ export declare const mockDialog: {
24
+ showOpenDialog: import("vitest").Mock<() => Promise<{
25
+ canceled: boolean;
26
+ filePaths: string[];
27
+ }>>;
28
+ showSaveDialog: import("vitest").Mock<() => Promise<{
29
+ canceled: boolean;
30
+ filePath: string;
31
+ }>>;
32
+ showMessageBox: import("vitest").Mock<() => Promise<{
33
+ response: number;
34
+ }>>;
35
+ showErrorBox: import("vitest").Mock<(...args: any[]) => any>;
36
+ };
37
+ export declare const mockSession: {
38
+ defaultSession: {
39
+ webRequest: {
40
+ onHeadersReceived: import("vitest").Mock<(...args: any[]) => any>;
41
+ };
42
+ };
43
+ };
44
+ export declare const mockElectron: {
45
+ app: {
46
+ getPath: import("vitest").Mock<(name: string) => string>;
47
+ getVersion: import("vitest").Mock<() => string>;
48
+ getName: import("vitest").Mock<() => string>;
49
+ quit: import("vitest").Mock<(...args: any[]) => any>;
50
+ exit: import("vitest").Mock<(...args: any[]) => any>;
51
+ on: import("vitest").Mock<(...args: any[]) => any>;
52
+ once: import("vitest").Mock<(...args: any[]) => any>;
53
+ removeListener: import("vitest").Mock<(...args: any[]) => any>;
54
+ whenReady: import("vitest").Mock<() => Promise<void>>;
55
+ isReady: import("vitest").Mock<() => boolean>;
56
+ getAppPath: import("vitest").Mock<() => string>;
57
+ };
58
+ BrowserWindow: import("vitest").Mock<(...args: any[]) => any>;
59
+ ipcMain: {
60
+ on: import("vitest").Mock<(...args: any[]) => any>;
61
+ once: import("vitest").Mock<(...args: any[]) => any>;
62
+ handle: import("vitest").Mock<(...args: any[]) => any>;
63
+ removeHandler: import("vitest").Mock<(...args: any[]) => any>;
64
+ removeListener: import("vitest").Mock<(...args: any[]) => any>;
65
+ removeAllListeners: import("vitest").Mock<(...args: any[]) => any>;
66
+ };
67
+ dialog: {
68
+ showOpenDialog: import("vitest").Mock<() => Promise<{
69
+ canceled: boolean;
70
+ filePaths: string[];
71
+ }>>;
72
+ showSaveDialog: import("vitest").Mock<() => Promise<{
73
+ canceled: boolean;
74
+ filePath: string;
75
+ }>>;
76
+ showMessageBox: import("vitest").Mock<() => Promise<{
77
+ response: number;
78
+ }>>;
79
+ showErrorBox: import("vitest").Mock<(...args: any[]) => any>;
80
+ };
81
+ session: {
82
+ defaultSession: {
83
+ webRequest: {
84
+ onHeadersReceived: import("vitest").Mock<(...args: any[]) => any>;
85
+ };
86
+ };
87
+ };
88
+ };
@@ -0,0 +1,76 @@
1
+ import { vi } from "vitest";
2
+ export const mockApp = {
3
+ getPath: vi.fn((name) => `/mock/path/${name}`),
4
+ getVersion: vi.fn(() => "1.0.0"),
5
+ getName: vi.fn(() => "MockApp"),
6
+ quit: vi.fn(),
7
+ exit: vi.fn(),
8
+ on: vi.fn(),
9
+ once: vi.fn(),
10
+ removeListener: vi.fn(),
11
+ whenReady: vi.fn(() => Promise.resolve()),
12
+ isReady: vi.fn(() => true),
13
+ getAppPath: vi.fn(() => "/mock/app"),
14
+ };
15
+ export const mockBrowserWindow = vi.fn().mockImplementation(() => ({
16
+ loadURL: vi.fn(() => Promise.resolve()),
17
+ loadFile: vi.fn(() => Promise.resolve()),
18
+ on: vi.fn(),
19
+ once: vi.fn(),
20
+ webContents: {
21
+ send: vi.fn(),
22
+ on: vi.fn(),
23
+ executeJavaScript: vi.fn(() => Promise.resolve()),
24
+ openDevTools: vi.fn(),
25
+ closeDevTools: vi.fn(),
26
+ },
27
+ show: vi.fn(),
28
+ hide: vi.fn(),
29
+ close: vi.fn(),
30
+ destroy: vi.fn(),
31
+ isDestroyed: vi.fn(() => false),
32
+ isFocused: vi.fn(() => true),
33
+ focus: vi.fn(),
34
+ id: 1,
35
+ }));
36
+ // Add static methods to mockBrowserWindow
37
+ Object.assign(mockBrowserWindow, {
38
+ getAllWindows: vi.fn(() => []),
39
+ });
40
+ export const mockIpcMain = {
41
+ on: vi.fn(),
42
+ once: vi.fn(),
43
+ handle: vi.fn(),
44
+ removeHandler: vi.fn(),
45
+ removeListener: vi.fn(),
46
+ removeAllListeners: vi.fn(),
47
+ };
48
+ export const mockDialog = {
49
+ showOpenDialog: vi.fn(() => Promise.resolve({
50
+ canceled: false,
51
+ filePaths: ["/mock/file.txt"],
52
+ })),
53
+ showSaveDialog: vi.fn(() => Promise.resolve({
54
+ canceled: false,
55
+ filePath: "/mock/save.txt",
56
+ })),
57
+ showMessageBox: vi.fn(() => Promise.resolve({
58
+ response: 0,
59
+ })),
60
+ showErrorBox: vi.fn(),
61
+ };
62
+ export const mockSession = {
63
+ defaultSession: {
64
+ webRequest: {
65
+ onHeadersReceived: vi.fn(),
66
+ },
67
+ },
68
+ };
69
+ export const mockElectron = {
70
+ app: mockApp,
71
+ BrowserWindow: mockBrowserWindow,
72
+ ipcMain: mockIpcMain,
73
+ dialog: mockDialog,
74
+ session: mockSession,
75
+ };
76
+ vi.mock("electron", () => mockElectron);