@devisfuture/electron-modular 1.1.10 → 1.1.11

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 (46) hide show
  1. package/dist/index.js +0 -8
  2. package/package.json +1 -1
  3. package/dist/@core/__tests__/container.test.d.ts +0 -1
  4. package/dist/@core/__tests__/container.test.js +0 -409
  5. package/dist/@core/bootstrap/__tests__/bootstrap.test.d.ts +0 -1
  6. package/dist/@core/bootstrap/__tests__/bootstrap.test.js +0 -131
  7. package/dist/@core/bootstrap/__tests__/initialize-module.test.d.ts +0 -1
  8. package/dist/@core/bootstrap/__tests__/initialize-module.test.js +0 -140
  9. package/dist/@core/bootstrap/__tests__/instantiate-module.test.d.ts +0 -1
  10. package/dist/@core/bootstrap/__tests__/instantiate-module.test.js +0 -174
  11. package/dist/@core/bootstrap/__tests__/register-imports.test.d.ts +0 -1
  12. package/dist/@core/bootstrap/__tests__/register-imports.test.js +0 -112
  13. package/dist/@core/bootstrap/__tests__/register-ipc-handlers.test.d.ts +0 -1
  14. package/dist/@core/bootstrap/__tests__/register-ipc-handlers.test.js +0 -68
  15. package/dist/@core/bootstrap/__tests__/register-providers.test.d.ts +0 -1
  16. package/dist/@core/bootstrap/__tests__/register-providers.test.js +0 -132
  17. package/dist/@core/bootstrap/__tests__/register-windows.test.d.ts +0 -1
  18. package/dist/@core/bootstrap/__tests__/register-windows.test.js +0 -109
  19. package/dist/@core/bootstrap/__tests__/settings.test.d.ts +0 -1
  20. package/dist/@core/bootstrap/__tests__/settings.test.js +0 -141
  21. package/dist/@core/control-window/__tests__/cache.test.d.ts +0 -1
  22. package/dist/@core/control-window/__tests__/cache.test.js +0 -50
  23. package/dist/@core/control-window/__tests__/destroy.test.d.ts +0 -1
  24. package/dist/@core/control-window/__tests__/destroy.test.js +0 -69
  25. package/dist/@core/control-window/__tests__/receive.test.d.ts +0 -1
  26. package/dist/@core/control-window/__tests__/receive.test.js +0 -68
  27. package/dist/@core/decorators/__tests__/inject.test.d.ts +0 -1
  28. package/dist/@core/decorators/__tests__/inject.test.js +0 -174
  29. package/dist/@core/decorators/__tests__/injectable.test.d.ts +0 -1
  30. package/dist/@core/decorators/__tests__/injectable.test.js +0 -73
  31. package/dist/@core/decorators/__tests__/ipc-handler.test.d.ts +0 -1
  32. package/dist/@core/decorators/__tests__/ipc-handler.test.js +0 -72
  33. package/dist/@core/decorators/__tests__/rg-module.test.d.ts +0 -1
  34. package/dist/@core/decorators/__tests__/rg-module.test.js +0 -135
  35. package/dist/@core/decorators/__tests__/window-manager.test.d.ts +0 -1
  36. package/dist/@core/decorators/__tests__/window-manager.test.js +0 -110
  37. package/dist/@core/errors/__tests__/index.test.d.ts +0 -1
  38. package/dist/@core/errors/__tests__/index.test.js +0 -82
  39. package/dist/@core/utils/__tests__/dependency-tokens.test.d.ts +0 -1
  40. package/dist/@core/utils/__tests__/dependency-tokens.test.js +0 -186
  41. package/dist/__mocks__/electron.d.ts +0 -88
  42. package/dist/__mocks__/electron.js +0 -76
  43. package/dist/__tests__/config.test.d.ts +0 -1
  44. package/dist/__tests__/config.test.js +0 -24
  45. package/dist/__tests__/setup.d.ts +0 -1
  46. package/dist/__tests__/setup.js +0 -9
@@ -1,109 +0,0 @@
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, vi, beforeEach } from "vitest";
8
- import { registerWindows } from "../register-windows.js";
9
- import { container } from "../../container.js";
10
- import { WindowManager } from "../../decorators/window-manager.js";
11
- import "reflect-metadata/lite";
12
- describe("registerWindows", () => {
13
- let TestModule;
14
- beforeEach(() => {
15
- TestModule = class TestModule {
16
- };
17
- container.addModule(TestModule, { providers: [] });
18
- vi.clearAllMocks();
19
- });
20
- it("should return early if no windows in metadata", async () => {
21
- const metadata = {};
22
- await expect(registerWindows(TestModule, metadata)).resolves.toBeUndefined();
23
- });
24
- it("should register window with hash", async () => {
25
- let MainWindow = class MainWindow {
26
- };
27
- MainWindow = __decorate([
28
- WindowManager({
29
- hash: "main-window",
30
- options: { width: 800, height: 600 },
31
- })
32
- ], MainWindow);
33
- const metadata = {
34
- windows: [MainWindow],
35
- };
36
- await registerWindows(TestModule, metadata);
37
- const provider = container.getProvider(TestModule, "main-window");
38
- expect(provider).toBeDefined();
39
- expect(provider).toHaveProperty("metadata");
40
- expect(provider).toHaveProperty("windowClass");
41
- });
42
- it("should register multiple windows", async () => {
43
- let MainWindow = class MainWindow {
44
- };
45
- MainWindow = __decorate([
46
- WindowManager({
47
- hash: "main-window",
48
- options: { width: 800 },
49
- })
50
- ], MainWindow);
51
- let SettingsWindow = class SettingsWindow {
52
- };
53
- SettingsWindow = __decorate([
54
- WindowManager({
55
- hash: "settings-window",
56
- options: { width: 600 },
57
- })
58
- ], SettingsWindow);
59
- const metadata = {
60
- windows: [MainWindow, SettingsWindow],
61
- };
62
- await registerWindows(TestModule, metadata);
63
- const mainProvider = container.getProvider(TestModule, "main-window");
64
- const settingsProvider = container.getProvider(TestModule, "settings-window");
65
- expect(mainProvider).toBeDefined();
66
- expect(settingsProvider).toBeDefined();
67
- });
68
- it("should not register window without hash", async () => {
69
- let NoHashWindow = class NoHashWindow {
70
- };
71
- NoHashWindow = __decorate([
72
- WindowManager({
73
- options: { width: 800 },
74
- })
75
- ], NoHashWindow);
76
- const metadata = {
77
- windows: [NoHashWindow],
78
- };
79
- await registerWindows(TestModule, metadata);
80
- // Since hash is undefined, it shouldn't register
81
- const provider = container.getProvider(TestModule, undefined);
82
- expect(provider).toBeUndefined();
83
- });
84
- it("should handle empty windows array", async () => {
85
- const metadata = {
86
- windows: [],
87
- };
88
- await expect(registerWindows(TestModule, metadata)).resolves.toBeUndefined();
89
- });
90
- it("should store window metadata and class", async () => {
91
- const windowOptions = {
92
- name: "test",
93
- hash: "test-window",
94
- options: { width: 1024, height: 768 },
95
- };
96
- let TestWindow = class TestWindow {
97
- };
98
- TestWindow = __decorate([
99
- WindowManager(windowOptions)
100
- ], TestWindow);
101
- const metadata = {
102
- windows: [TestWindow],
103
- };
104
- await registerWindows(TestModule, metadata);
105
- const provider = container.getProvider(TestModule, "test-window");
106
- expect(provider.windowClass).toBe(TestWindow);
107
- expect(provider.metadata).toEqual(windowOptions);
108
- });
109
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,141 +0,0 @@
1
- import { describe, it, expect, beforeEach } from "vitest";
2
- import { initSettings, getSettings } from "../settings.js";
3
- import { SettingsNotInitializedError } from "../../errors/index.js";
4
- describe("settings", () => {
5
- beforeEach(() => {
6
- // Clear settings before each test
7
- // Since we can't directly clear the Map, we'll re-initialize
8
- });
9
- describe("initSettings", () => {
10
- it("should initialize settings", () => {
11
- const settings = {
12
- localhostPort: "3000",
13
- folders: {
14
- distRenderer: "dist-renderer",
15
- distMain: "dist-main",
16
- },
17
- };
18
- initSettings(settings);
19
- const retrieved = getSettings();
20
- expect(retrieved).toEqual(settings);
21
- });
22
- it("should initialize with CSP sources", () => {
23
- const settings = {
24
- localhostPort: "3000",
25
- folders: {
26
- distRenderer: "dist-renderer",
27
- distMain: "dist-main",
28
- },
29
- cspConnectSources: ["https://api.example.com"],
30
- };
31
- initSettings(settings);
32
- const retrieved = getSettings();
33
- expect(retrieved.cspConnectSources).toEqual(["https://api.example.com"]);
34
- });
35
- it("should overwrite existing settings", () => {
36
- const settings1 = {
37
- localhostPort: "3000",
38
- folders: {
39
- distRenderer: "dist",
40
- distMain: "main",
41
- },
42
- };
43
- const settings2 = {
44
- localhostPort: "4000",
45
- folders: {
46
- distRenderer: "renderer",
47
- distMain: "backend",
48
- },
49
- };
50
- initSettings(settings1);
51
- initSettings(settings2);
52
- const retrieved = getSettings();
53
- expect(retrieved).toEqual(settings2);
54
- expect(retrieved.localhostPort).toBe("4000");
55
- });
56
- });
57
- describe("getSettings", () => {
58
- it("should throw error if settings not initialized", () => {
59
- // Create a new scenario where settings might not be initialized
60
- // Since we can't clear the Map directly, this test demonstrates the error
61
- expect(() => {
62
- // This would throw if settings were not previously initialized
63
- // For the actual test, we rely on beforeEach isolation
64
- }).not.toThrow();
65
- });
66
- it("should return initialized settings", () => {
67
- const settings = {
68
- localhostPort: "5000",
69
- folders: {
70
- distRenderer: "public",
71
- distMain: "server",
72
- },
73
- };
74
- initSettings(settings);
75
- const retrieved = getSettings();
76
- expect(retrieved).toEqual(settings);
77
- expect(retrieved.localhostPort).toBe("5000");
78
- });
79
- it("should return same reference on multiple calls", () => {
80
- const settings = {
81
- localhostPort: "3000",
82
- folders: {
83
- distRenderer: "dist-renderer",
84
- distMain: "dist-main",
85
- },
86
- };
87
- initSettings(settings);
88
- const retrieved1 = getSettings();
89
- const retrieved2 = getSettings();
90
- expect(retrieved1).toBe(retrieved2);
91
- });
92
- it("should preserve all settings properties", () => {
93
- const settings = {
94
- localhostPort: "8080",
95
- folders: {
96
- distRenderer: "build/renderer",
97
- distMain: "build/main",
98
- },
99
- cspConnectSources: [
100
- "https://api1.example.com",
101
- "https://api2.example.com",
102
- ],
103
- };
104
- initSettings(settings);
105
- const retrieved = getSettings();
106
- expect(retrieved.localhostPort).toBe("8080");
107
- expect(retrieved.folders.distRenderer).toBe("build/renderer");
108
- expect(retrieved.folders.distMain).toBe("build/main");
109
- expect(retrieved.cspConnectSources).toHaveLength(2);
110
- });
111
- });
112
- describe("type safety", () => {
113
- it("should require all mandatory fields", () => {
114
- const settings = {
115
- localhostPort: "3000",
116
- folders: {
117
- distRenderer: "dist-renderer",
118
- distMain: "dist-main",
119
- },
120
- };
121
- initSettings(settings);
122
- const retrieved = getSettings();
123
- expect(retrieved.localhostPort).toBeDefined();
124
- expect(retrieved.folders).toBeDefined();
125
- expect(retrieved.folders.distRenderer).toBeDefined();
126
- expect(retrieved.folders.distMain).toBeDefined();
127
- });
128
- it("should handle optional CSP sources", () => {
129
- const settingsWithoutCSP = {
130
- localhostPort: "3000",
131
- folders: {
132
- distRenderer: "dist-renderer",
133
- distMain: "dist-main",
134
- },
135
- };
136
- initSettings(settingsWithoutCSP);
137
- const retrieved = getSettings();
138
- expect(retrieved.cspConnectSources).toBeUndefined();
139
- });
140
- });
141
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,50 +0,0 @@
1
- import { describe, it, expect, beforeEach } from "vitest";
2
- import { cacheWindows } from "../cache.js";
3
- describe("cacheWindows", () => {
4
- beforeEach(() => {
5
- cacheWindows.clear();
6
- });
7
- it("should be a Map instance", () => {
8
- expect(cacheWindows).toBeInstanceOf(Map);
9
- });
10
- it("should store window references", () => {
11
- const mockWindow = { id: 1 };
12
- cacheWindows.set("main", mockWindow);
13
- expect(cacheWindows.get("main")).toBe(mockWindow);
14
- });
15
- it("should allow multiple windows", () => {
16
- const window1 = { id: 1 };
17
- const window2 = { id: 2 };
18
- cacheWindows.set("main", window1);
19
- cacheWindows.set("settings", window2);
20
- expect(cacheWindows.get("main")).toBe(window1);
21
- expect(cacheWindows.get("settings")).toBe(window2);
22
- expect(cacheWindows.size).toBe(2);
23
- });
24
- it("should overwrite existing entries", () => {
25
- const window1 = { id: 1 };
26
- const window2 = { id: 2 };
27
- cacheWindows.set("main", window1);
28
- cacheWindows.set("main", window2);
29
- expect(cacheWindows.get("main")).toBe(window2);
30
- expect(cacheWindows.size).toBe(1);
31
- });
32
- it("should delete entries", () => {
33
- const mockWindow = { id: 1 };
34
- cacheWindows.set("main", mockWindow);
35
- cacheWindows.delete("main");
36
- expect(cacheWindows.get("main")).toBeUndefined();
37
- });
38
- it("should clear all entries", () => {
39
- cacheWindows.set("main", { id: 1 });
40
- cacheWindows.set("settings", { id: 2 });
41
- cacheWindows.clear();
42
- expect(cacheWindows.size).toBe(0);
43
- });
44
- it("should check if key exists", () => {
45
- const mockWindow = { id: 1 };
46
- cacheWindows.set("main", mockWindow);
47
- expect(cacheWindows.has("main")).toBe(true);
48
- expect(cacheWindows.has("settings")).toBe(false);
49
- });
50
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,69 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { BrowserWindow } from "electron";
3
- import { destroyWindows } from "../destroy.js";
4
- describe("destroyWindows", () => {
5
- beforeEach(() => {
6
- vi.clearAllMocks();
7
- });
8
- it("should destroy all windows", () => {
9
- const mockWindow1 = {
10
- isDestroyed: vi.fn(() => false),
11
- destroy: vi.fn(),
12
- };
13
- const mockWindow2 = {
14
- isDestroyed: vi.fn(() => false),
15
- destroy: vi.fn(),
16
- };
17
- vi.spyOn(BrowserWindow, "getAllWindows").mockReturnValue([
18
- mockWindow1,
19
- mockWindow2,
20
- ]);
21
- destroyWindows();
22
- expect(mockWindow1.destroy).toHaveBeenCalledOnce();
23
- expect(mockWindow2.destroy).toHaveBeenCalledOnce();
24
- });
25
- it("should not destroy already destroyed windows", () => {
26
- const mockWindow1 = {
27
- isDestroyed: vi.fn(() => true),
28
- destroy: vi.fn(),
29
- };
30
- const mockWindow2 = {
31
- isDestroyed: vi.fn(() => false),
32
- destroy: vi.fn(),
33
- };
34
- vi.spyOn(BrowserWindow, "getAllWindows").mockReturnValue([
35
- mockWindow1,
36
- mockWindow2,
37
- ]);
38
- destroyWindows();
39
- expect(mockWindow1.destroy).not.toHaveBeenCalled();
40
- expect(mockWindow2.destroy).toHaveBeenCalledOnce();
41
- });
42
- it("should handle empty window list", () => {
43
- vi.spyOn(BrowserWindow, "getAllWindows").mockReturnValue([]);
44
- expect(() => destroyWindows()).not.toThrow();
45
- });
46
- it("should handle single window", () => {
47
- const mockWindow = {
48
- isDestroyed: vi.fn(() => false),
49
- destroy: vi.fn(),
50
- };
51
- vi.spyOn(BrowserWindow, "getAllWindows").mockReturnValue([
52
- mockWindow,
53
- ]);
54
- destroyWindows();
55
- expect(mockWindow.destroy).toHaveBeenCalledOnce();
56
- });
57
- it("should check isDestroyed before destroying", () => {
58
- const mockWindow = {
59
- isDestroyed: vi.fn(() => false),
60
- destroy: vi.fn(),
61
- };
62
- vi.spyOn(BrowserWindow, "getAllWindows").mockReturnValue([
63
- mockWindow,
64
- ]);
65
- destroyWindows();
66
- expect(mockWindow.isDestroyed).toHaveBeenCalled();
67
- expect(mockWindow.destroy).toHaveBeenCalled();
68
- });
69
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,68 +0,0 @@
1
- import { describe, it, expect, beforeEach } from "vitest";
2
- import { getWindow } from "../receive.js";
3
- import { cacheWindows } from "../cache.js";
4
- describe("getWindow", () => {
5
- beforeEach(() => {
6
- cacheWindows.clear();
7
- });
8
- it("should return undefined if window not found", () => {
9
- const result = getWindow("nonexistent");
10
- expect(result).toBeUndefined();
11
- });
12
- it("should return cached window", () => {
13
- const mockWindow = {
14
- id: 1,
15
- isDestroyed: () => false,
16
- };
17
- cacheWindows.set("main", mockWindow);
18
- const result = getWindow("main");
19
- expect(result).toBe(mockWindow);
20
- });
21
- it("should return undefined if window is destroyed", () => {
22
- const mockWindow = {
23
- id: 1,
24
- isDestroyed: () => true,
25
- };
26
- cacheWindows.set("main", mockWindow);
27
- const result = getWindow("main");
28
- expect(result).toBeUndefined();
29
- });
30
- it("should return undefined if cached value is boolean", () => {
31
- cacheWindows.set("main", true);
32
- const result = getWindow("main");
33
- expect(result).toBeUndefined();
34
- });
35
- it("should handle different window names", () => {
36
- const mainWindow = {
37
- id: 1,
38
- isDestroyed: () => false,
39
- };
40
- const settingsWindow = {
41
- id: 2,
42
- isDestroyed: () => false,
43
- };
44
- cacheWindows.set("main", mainWindow);
45
- cacheWindows.set("settings", settingsWindow);
46
- expect(getWindow("main")).toBe(mainWindow);
47
- expect(getWindow("settings")).toBe(settingsWindow);
48
- });
49
- it("should handle string window names", () => {
50
- const mockWindow = {
51
- id: 1,
52
- isDestroyed: () => false,
53
- };
54
- cacheWindows.set("custom-window-name", mockWindow);
55
- const result = getWindow("custom-window-name");
56
- expect(result).toBe(mockWindow);
57
- });
58
- it("should return undefined after window is removed from cache", () => {
59
- const mockWindow = {
60
- id: 1,
61
- isDestroyed: () => false,
62
- };
63
- cacheWindows.set("main", mockWindow);
64
- cacheWindows.delete("main");
65
- const result = getWindow("main");
66
- expect(result).toBeUndefined();
67
- });
68
- });
@@ -1 +0,0 @@
1
- import "reflect-metadata/lite";
@@ -1,174 +0,0 @@
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 } from "vitest";
14
- import { Inject, getInjectedTokens } from "../inject.js";
15
- import "reflect-metadata/lite";
16
- describe("Inject decorator", () => {
17
- describe("@Inject", () => {
18
- it("should store injection token for parameter", () => {
19
- const TOKEN = Symbol("test-token");
20
- let TestService = class TestService {
21
- dependency;
22
- constructor(dependency) {
23
- this.dependency = dependency;
24
- }
25
- };
26
- TestService = __decorate([
27
- __param(0, Inject(TOKEN)),
28
- __metadata("design:paramtypes", [Object])
29
- ], TestService);
30
- const tokens = getInjectedTokens(TestService);
31
- expect(tokens[0]).toBe(TOKEN);
32
- });
33
- it("should handle multiple injection tokens", () => {
34
- const TOKEN1 = Symbol("token-1");
35
- const TOKEN2 = Symbol("token-2");
36
- const TOKEN3 = Symbol("token-3");
37
- let TestService = class TestService {
38
- dep1;
39
- dep2;
40
- dep3;
41
- constructor(dep1, dep2, dep3) {
42
- this.dep1 = dep1;
43
- this.dep2 = dep2;
44
- this.dep3 = dep3;
45
- }
46
- };
47
- TestService = __decorate([
48
- __param(0, Inject(TOKEN1)),
49
- __param(1, Inject(TOKEN2)),
50
- __param(2, Inject(TOKEN3)),
51
- __metadata("design:paramtypes", [Object, Object, Object])
52
- ], TestService);
53
- const tokens = getInjectedTokens(TestService);
54
- expect(tokens[0]).toBe(TOKEN1);
55
- expect(tokens[1]).toBe(TOKEN2);
56
- expect(tokens[2]).toBe(TOKEN3);
57
- });
58
- it("should handle string tokens", () => {
59
- const TOKEN = "StringToken";
60
- let TestService = class TestService {
61
- dependency;
62
- constructor(dependency) {
63
- this.dependency = dependency;
64
- }
65
- };
66
- TestService = __decorate([
67
- __param(0, Inject(TOKEN)),
68
- __metadata("design:paramtypes", [Object])
69
- ], TestService);
70
- const tokens = getInjectedTokens(TestService);
71
- expect(tokens[0]).toBe(TOKEN);
72
- });
73
- it("should handle class constructor tokens", () => {
74
- class DependencyClass {
75
- }
76
- let TestService = class TestService {
77
- dependency;
78
- constructor(dependency) {
79
- this.dependency = dependency;
80
- }
81
- };
82
- TestService = __decorate([
83
- __param(0, Inject(DependencyClass)),
84
- __metadata("design:paramtypes", [Object])
85
- ], TestService);
86
- const tokens = getInjectedTokens(TestService);
87
- expect(tokens[0]).toBe(DependencyClass);
88
- });
89
- it("should ignore property decorators", () => {
90
- const TOKEN = Symbol("test-token");
91
- class TestService {
92
- // @ts-expect-error - Testing that property decorators are ignored (Inject is a ParameterDecorator)
93
- property;
94
- }
95
- __decorate([
96
- Inject(TOKEN),
97
- __metadata("design:type", Object)
98
- ], TestService.prototype, "property", void 0);
99
- const tokens = getInjectedTokens(TestService);
100
- expect(Object.keys(tokens).length).toBe(0);
101
- });
102
- it("should handle mixed decorated and non-decorated parameters", () => {
103
- const TOKEN = Symbol("token");
104
- class Dependency {
105
- }
106
- let TestService = class TestService {
107
- injected;
108
- notInjected;
109
- constructor(injected, notInjected) {
110
- this.injected = injected;
111
- this.notInjected = notInjected;
112
- }
113
- };
114
- TestService = __decorate([
115
- __param(0, Inject(TOKEN)),
116
- __metadata("design:paramtypes", [Object, Dependency])
117
- ], TestService);
118
- const tokens = getInjectedTokens(TestService);
119
- expect(tokens[0]).toBe(TOKEN);
120
- });
121
- it("should preserve parameter indexes correctly", () => {
122
- const TOKEN1 = Symbol("token-1");
123
- const TOKEN3 = Symbol("token-3");
124
- class Dep2 {
125
- }
126
- let TestService = class TestService {
127
- dep1;
128
- dep2;
129
- dep3;
130
- constructor(dep1, dep2, dep3) {
131
- this.dep1 = dep1;
132
- this.dep2 = dep2;
133
- this.dep3 = dep3;
134
- }
135
- };
136
- TestService = __decorate([
137
- __param(0, Inject(TOKEN1)),
138
- __param(2, Inject(TOKEN3)),
139
- __metadata("design:paramtypes", [Object, Dep2, Object])
140
- ], TestService);
141
- const tokens = getInjectedTokens(TestService);
142
- expect(tokens[0]).toBe(TOKEN1);
143
- expect(tokens[2]).toBe(TOKEN3);
144
- });
145
- });
146
- describe("getInjectedTokens", () => {
147
- it("should return empty object for class without injections", () => {
148
- class TestService {
149
- }
150
- const tokens = getInjectedTokens(TestService);
151
- expect(tokens).toEqual({});
152
- });
153
- it("should return empty object for class with no constructor", () => {
154
- class TestService {
155
- method() { }
156
- }
157
- const tokens = getInjectedTokens(TestService);
158
- expect(tokens).toEqual({});
159
- });
160
- it("should return metadata for decorated parameters", () => {
161
- const TOKEN = Symbol("test");
162
- let TestService = class TestService {
163
- constructor(dep) { }
164
- };
165
- TestService = __decorate([
166
- __param(0, Inject(TOKEN)),
167
- __metadata("design:paramtypes", [Object])
168
- ], TestService);
169
- const tokens = getInjectedTokens(TestService);
170
- expect(Object.keys(tokens).length).toBeGreaterThan(0);
171
- expect(tokens[0]).toBe(TOKEN);
172
- });
173
- });
174
- });
@@ -1 +0,0 @@
1
- import "reflect-metadata/lite";