@mdfriday/foundry 25.8.8 → 25.8.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 (190) hide show
  1. package/README.md +4 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/application/incremental-build-coordinator.d.ts +2 -0
  7. package/dist/internal/application/incremental-build-coordinator.d.ts.map +1 -1
  8. package/dist/internal/application/incremental-build-coordinator.js +2 -2
  9. package/dist/internal/application/incremental-build-coordinator.js.map +1 -1
  10. package/dist/internal/application/ssg.d.ts +6 -5
  11. package/dist/internal/application/ssg.d.ts.map +1 -1
  12. package/dist/internal/application/ssg.js +12 -11
  13. package/dist/internal/application/ssg.js.map +1 -1
  14. package/dist/internal/domain/config/tests/entity-config.test.d.ts +2 -0
  15. package/dist/internal/domain/config/tests/entity-config.test.d.ts.map +1 -0
  16. package/dist/internal/domain/config/tests/entity-config.test.js +199 -0
  17. package/dist/internal/domain/config/tests/entity-config.test.js.map +1 -0
  18. package/dist/internal/domain/config/tests/entity-root.test.d.ts +2 -0
  19. package/dist/internal/domain/config/tests/entity-root.test.d.ts.map +1 -0
  20. package/dist/internal/domain/config/tests/entity-root.test.js +235 -0
  21. package/dist/internal/domain/config/tests/entity-root.test.js.map +1 -0
  22. package/dist/internal/domain/config/tests/factory-config.test.d.ts +2 -0
  23. package/dist/internal/domain/config/tests/factory-config.test.d.ts.map +1 -0
  24. package/dist/internal/domain/config/tests/factory-config.test.js +84 -0
  25. package/dist/internal/domain/config/tests/factory-config.test.js.map +1 -0
  26. package/dist/internal/domain/config/tests/index.test.d.ts +2 -0
  27. package/dist/internal/domain/config/tests/index.test.d.ts.map +1 -0
  28. package/dist/internal/domain/config/tests/index.test.js +197 -0
  29. package/dist/internal/domain/config/tests/index.test.js.map +1 -0
  30. package/dist/internal/domain/config/tests/mock-fs.d.ts +26 -0
  31. package/dist/internal/domain/config/tests/mock-fs.d.ts.map +1 -0
  32. package/dist/internal/domain/config/tests/mock-fs.js +281 -0
  33. package/dist/internal/domain/config/tests/mock-fs.js.map +1 -0
  34. package/dist/internal/domain/config/tests/type.test.d.ts +2 -0
  35. package/dist/internal/domain/config/tests/type.test.d.ts.map +1 -0
  36. package/dist/internal/domain/config/tests/type.test.js +272 -0
  37. package/dist/internal/domain/config/tests/type.test.js.map +1 -0
  38. package/dist/internal/domain/config/tests/vo-module.test.d.ts +2 -0
  39. package/dist/internal/domain/config/tests/vo-module.test.d.ts.map +1 -0
  40. package/dist/internal/domain/config/tests/vo-module.test.js +267 -0
  41. package/dist/internal/domain/config/tests/vo-module.test.js.map +1 -0
  42. package/dist/internal/domain/config/tests/vo-root.test.d.ts +2 -0
  43. package/dist/internal/domain/config/tests/vo-root.test.d.ts.map +1 -0
  44. package/dist/internal/domain/config/tests/vo-root.test.js +165 -0
  45. package/dist/internal/domain/config/tests/vo-root.test.js.map +1 -0
  46. package/dist/internal/domain/config/tests/vo-service.test.d.ts +2 -0
  47. package/dist/internal/domain/config/tests/vo-service.test.d.ts.map +1 -0
  48. package/dist/internal/domain/config/tests/vo-service.test.js +266 -0
  49. package/dist/internal/domain/config/tests/vo-service.test.js.map +1 -0
  50. package/dist/internal/domain/content/factory/hub.js +1 -1
  51. package/dist/internal/domain/content/factory/hub.js.map +1 -1
  52. package/dist/internal/domain/content/type.d.ts +2 -1
  53. package/dist/internal/domain/content/type.d.ts.map +1 -1
  54. package/dist/internal/domain/content/type.js.map +1 -1
  55. package/dist/internal/domain/fs/entity/overlayfs.js +1 -1
  56. package/dist/internal/domain/fs/entity/overlayfs.js.map +1 -1
  57. package/dist/internal/domain/fs/tests/entity-basefs.test.d.ts +2 -0
  58. package/dist/internal/domain/fs/tests/entity-basefs.test.d.ts.map +1 -0
  59. package/dist/internal/domain/fs/tests/entity-basefs.test.js +279 -0
  60. package/dist/internal/domain/fs/tests/entity-basefs.test.js.map +1 -0
  61. package/dist/internal/domain/fs/tests/entity-fs.test.d.ts +2 -0
  62. package/dist/internal/domain/fs/tests/entity-fs.test.d.ts.map +1 -0
  63. package/dist/internal/domain/fs/tests/entity-fs.test.js +230 -0
  64. package/dist/internal/domain/fs/tests/entity-fs.test.js.map +1 -0
  65. package/dist/internal/domain/fs/tests/entity-originfs.test.d.ts +2 -0
  66. package/dist/internal/domain/fs/tests/entity-originfs.test.d.ts.map +1 -0
  67. package/dist/internal/domain/fs/tests/entity-originfs.test.js +47 -0
  68. package/dist/internal/domain/fs/tests/entity-originfs.test.js.map +1 -0
  69. package/dist/internal/domain/fs/tests/entity-overlaydir.test.d.ts +2 -0
  70. package/dist/internal/domain/fs/tests/entity-overlaydir.test.d.ts.map +1 -0
  71. package/dist/internal/domain/fs/tests/entity-overlaydir.test.js +293 -0
  72. package/dist/internal/domain/fs/tests/entity-overlaydir.test.js.map +1 -0
  73. package/dist/internal/domain/fs/tests/entity-overlayfs.test.d.ts +2 -0
  74. package/dist/internal/domain/fs/tests/entity-overlayfs.test.d.ts.map +1 -0
  75. package/dist/internal/domain/fs/tests/entity-overlayfs.test.js +281 -0
  76. package/dist/internal/domain/fs/tests/entity-overlayfs.test.js.map +1 -0
  77. package/dist/internal/domain/fs/tests/entity-service.test.d.ts +2 -0
  78. package/dist/internal/domain/fs/tests/entity-service.test.d.ts.map +1 -0
  79. package/dist/internal/domain/fs/tests/entity-service.test.js +43 -0
  80. package/dist/internal/domain/fs/tests/entity-service.test.js.map +1 -0
  81. package/dist/internal/domain/fs/tests/factory-fs.test.d.ts +2 -0
  82. package/dist/internal/domain/fs/tests/factory-fs.test.d.ts.map +1 -0
  83. package/dist/internal/domain/fs/tests/factory-fs.test.js +105 -0
  84. package/dist/internal/domain/fs/tests/factory-fs.test.js.map +1 -0
  85. package/dist/internal/domain/fs/tests/type.test.d.ts +2 -0
  86. package/dist/internal/domain/fs/tests/type.test.d.ts.map +1 -0
  87. package/dist/internal/domain/fs/tests/type.test.js +113 -0
  88. package/dist/internal/domain/fs/tests/type.test.js.map +1 -0
  89. package/dist/internal/domain/fs/tests/vo-dir.test.d.ts +2 -0
  90. package/dist/internal/domain/fs/tests/vo-dir.test.d.ts.map +1 -0
  91. package/dist/internal/domain/fs/tests/vo-dir.test.js +211 -0
  92. package/dist/internal/domain/fs/tests/vo-dir.test.js.map +1 -0
  93. package/dist/internal/domain/fs/tests/vo-file.test.d.ts +2 -0
  94. package/dist/internal/domain/fs/tests/vo-file.test.d.ts.map +1 -0
  95. package/dist/internal/domain/fs/tests/vo-file.test.js +256 -0
  96. package/dist/internal/domain/fs/tests/vo-file.test.js.map +1 -0
  97. package/dist/internal/domain/fs/tests/vo-fileinfo.test.d.ts +2 -0
  98. package/dist/internal/domain/fs/tests/vo-fileinfo.test.d.ts.map +1 -0
  99. package/dist/internal/domain/fs/tests/vo-fileinfo.test.js +165 -0
  100. package/dist/internal/domain/fs/tests/vo-fileinfo.test.js.map +1 -0
  101. package/dist/internal/domain/fs/tests/vo-filemeta.test.d.ts +2 -0
  102. package/dist/internal/domain/fs/tests/vo-filemeta.test.d.ts.map +1 -0
  103. package/dist/internal/domain/fs/tests/vo-filemeta.test.js +171 -0
  104. package/dist/internal/domain/fs/tests/vo-filemeta.test.js.map +1 -0
  105. package/dist/internal/domain/fs/tests/vo-filesystemscollector.test.d.ts +2 -0
  106. package/dist/internal/domain/fs/tests/vo-filesystemscollector.test.d.ts.map +1 -0
  107. package/dist/internal/domain/fs/tests/vo-filesystemscollector.test.js +298 -0
  108. package/dist/internal/domain/fs/tests/vo-filesystemscollector.test.js.map +1 -0
  109. package/dist/internal/domain/fs/tests/vo-filevitural.test.d.ts +2 -0
  110. package/dist/internal/domain/fs/tests/vo-filevitural.test.d.ts.map +1 -0
  111. package/dist/internal/domain/fs/tests/vo-filevitural.test.js +167 -0
  112. package/dist/internal/domain/fs/tests/vo-filevitural.test.js.map +1 -0
  113. package/dist/internal/domain/fs/tests/vo-incremental-file-collector.test.d.ts +2 -0
  114. package/dist/internal/domain/fs/tests/vo-incremental-file-collector.test.d.ts.map +1 -0
  115. package/dist/internal/domain/fs/tests/vo-incremental-file-collector.test.js +396 -0
  116. package/dist/internal/domain/fs/tests/vo-incremental-file-collector.test.js.map +1 -0
  117. package/dist/internal/domain/fs/tests/vo-osfs.test.d.ts +2 -0
  118. package/dist/internal/domain/fs/tests/vo-osfs.test.d.ts.map +1 -0
  119. package/dist/internal/domain/fs/tests/vo-osfs.test.js +363 -0
  120. package/dist/internal/domain/fs/tests/vo-osfs.test.js.map +1 -0
  121. package/dist/internal/domain/fs/tests/vo-overlayfs-factory.test.d.ts +2 -0
  122. package/dist/internal/domain/fs/tests/vo-overlayfs-factory.test.d.ts.map +1 -0
  123. package/dist/internal/domain/fs/tests/vo-overlayfs-factory.test.js +430 -0
  124. package/dist/internal/domain/fs/tests/vo-overlayfs-factory.test.js.map +1 -0
  125. package/dist/internal/domain/fs/tests/vo-overlayoptions.test.d.ts +2 -0
  126. package/dist/internal/domain/fs/tests/vo-overlayoptions.test.d.ts.map +1 -0
  127. package/dist/internal/domain/fs/tests/vo-overlayoptions.test.js +402 -0
  128. package/dist/internal/domain/fs/tests/vo-overlayoptions.test.js.map +1 -0
  129. package/dist/internal/domain/fs/tests/vo-static-copier.test.d.ts +2 -0
  130. package/dist/internal/domain/fs/tests/vo-static-copier.test.d.ts.map +1 -0
  131. package/dist/internal/domain/fs/tests/vo-static-copier.test.js +320 -0
  132. package/dist/internal/domain/fs/tests/vo-static-copier.test.js.map +1 -0
  133. package/dist/internal/domain/fs/tests/vo-walkway.test.d.ts +2 -0
  134. package/dist/internal/domain/fs/tests/vo-walkway.test.d.ts.map +1 -0
  135. package/dist/internal/domain/fs/tests/vo-walkway.test.js +295 -0
  136. package/dist/internal/domain/fs/tests/vo-walkway.test.js.map +1 -0
  137. package/dist/internal/domain/markdown/entity/markdown.d.ts +0 -21
  138. package/dist/internal/domain/markdown/entity/markdown.d.ts.map +1 -1
  139. package/dist/internal/domain/markdown/entity/markdown.js +2 -35
  140. package/dist/internal/domain/markdown/entity/markdown.js.map +1 -1
  141. package/dist/internal/domain/markdown/factory/markdown.d.ts +2 -38
  142. package/dist/internal/domain/markdown/factory/markdown.d.ts.map +1 -1
  143. package/dist/internal/domain/markdown/factory/markdown.js +2 -70
  144. package/dist/internal/domain/markdown/factory/markdown.js.map +1 -1
  145. package/dist/internal/domain/markdown/index.d.ts +0 -3
  146. package/dist/internal/domain/markdown/index.d.ts.map +1 -1
  147. package/dist/internal/domain/markdown/index.js +0 -3
  148. package/dist/internal/domain/markdown/index.js.map +1 -1
  149. package/dist/internal/domain/markdown/type.d.ts +1 -16
  150. package/dist/internal/domain/markdown/type.d.ts.map +1 -1
  151. package/dist/internal/domain/markdown/type.js.map +1 -1
  152. package/dist/internal/domain/markdown/vo/parserresult.d.ts +1 -60
  153. package/dist/internal/domain/markdown/vo/parserresult.d.ts.map +1 -1
  154. package/dist/internal/domain/markdown/vo/parserresult.js +1 -174
  155. package/dist/internal/domain/markdown/vo/parserresult.js.map +1 -1
  156. package/dist/internal/domain/paths/test/pathoperations.test.js +1 -1
  157. package/dist/internal/domain/paths/test/pathoperations.test.js.map +1 -1
  158. package/dist/internal/domain/template/vo/registry.d.ts.map +1 -1
  159. package/dist/internal/domain/template/vo/registry.js +33 -0
  160. package/dist/internal/domain/template/vo/registry.js.map +1 -1
  161. package/dist/pkg/log/manager.js +1 -1
  162. package/package.json +2 -25
  163. package/dist/internal/application/test-incremental-ssg.d.ts +0 -9
  164. package/dist/internal/application/test-incremental-ssg.d.ts.map +0 -1
  165. package/dist/internal/application/test-incremental-ssg.js +0 -83
  166. package/dist/internal/application/test-incremental-ssg.js.map +0 -1
  167. package/dist/internal/application/test-ssg.d.ts +0 -8
  168. package/dist/internal/application/test-ssg.d.ts.map +0 -1
  169. package/dist/internal/application/test-ssg.js +0 -30
  170. package/dist/internal/application/test-ssg.js.map +0 -1
  171. package/dist/internal/domain/markdown/test/external-adapter.test.d.ts +0 -2
  172. package/dist/internal/domain/markdown/test/external-adapter.test.d.ts.map +0 -1
  173. package/dist/internal/domain/markdown/test/external-adapter.test.js +0 -150
  174. package/dist/internal/domain/markdown/test/external-adapter.test.js.map +0 -1
  175. package/dist/internal/domain/markdown/test/markdown.test.d.ts +0 -2
  176. package/dist/internal/domain/markdown/test/markdown.test.d.ts.map +0 -1
  177. package/dist/internal/domain/markdown/test/markdown.test.js +0 -88
  178. package/dist/internal/domain/markdown/test/markdown.test.js.map +0 -1
  179. package/dist/internal/domain/markdown/vo/externaladapter.d.ts +0 -63
  180. package/dist/internal/domain/markdown/vo/externaladapter.d.ts.map +0 -1
  181. package/dist/internal/domain/markdown/vo/externaladapter.js +0 -194
  182. package/dist/internal/domain/markdown/vo/externaladapter.js.map +0 -1
  183. package/dist/internal/domain/markdown/vo/markdownit.d.ts +0 -33
  184. package/dist/internal/domain/markdown/vo/markdownit.d.ts.map +0 -1
  185. package/dist/internal/domain/markdown/vo/markdownit.js +0 -175
  186. package/dist/internal/domain/markdown/vo/markdownit.js.map +0 -1
  187. package/dist/pkg/web/server/example.d.ts +0 -2
  188. package/dist/pkg/web/server/example.d.ts.map +0 -1
  189. package/dist/pkg/web/server/example.js +0 -43
  190. package/dist/pkg/web/server/example.js.map +0 -1
@@ -0,0 +1,320 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const static_copier_1 = require("../vo/static-copier");
4
+ // Mock dependencies
5
+ jest.mock('@pkg/log', () => ({
6
+ getDomainLogger: () => ({
7
+ error: jest.fn(),
8
+ info: jest.fn(),
9
+ debug: jest.fn(),
10
+ warn: jest.fn(),
11
+ }),
12
+ }));
13
+ describe('StaticCopier Value Object', () => {
14
+ let mockSourceFs1;
15
+ let mockSourceFs2;
16
+ let mockTargetFs;
17
+ let mockFile;
18
+ let mockFileInfo;
19
+ let staticCopier;
20
+ beforeEach(() => {
21
+ mockFileInfo = {
22
+ name: jest.fn().mockReturnValue('test.txt'),
23
+ size: jest.fn().mockReturnValue(100),
24
+ mode: jest.fn().mockReturnValue(0o644),
25
+ modTime: jest.fn().mockReturnValue(new Date()),
26
+ isDir: jest.fn().mockReturnValue(false),
27
+ sys: jest.fn().mockReturnValue(null),
28
+ };
29
+ mockFile = {
30
+ close: jest.fn(),
31
+ read: jest.fn(),
32
+ readAt: jest.fn(),
33
+ seek: jest.fn(),
34
+ write: jest.fn(),
35
+ writeAt: jest.fn(),
36
+ name: jest.fn().mockReturnValue('/test.txt'),
37
+ readdir: jest.fn(),
38
+ readdirnames: jest.fn(),
39
+ stat: jest.fn().mockResolvedValue(mockFileInfo),
40
+ sync: jest.fn(),
41
+ truncate: jest.fn(),
42
+ writeString: jest.fn(),
43
+ };
44
+ mockSourceFs1 = {
45
+ name: jest.fn().mockReturnValue('SourceFs1'),
46
+ create: jest.fn(),
47
+ mkdir: jest.fn(),
48
+ mkdirAll: jest.fn(),
49
+ open: jest.fn().mockResolvedValue(mockFile),
50
+ openFile: jest.fn(),
51
+ remove: jest.fn(),
52
+ removeAll: jest.fn(),
53
+ rename: jest.fn(),
54
+ stat: jest.fn(),
55
+ chmod: jest.fn(),
56
+ chown: jest.fn(),
57
+ chtimes: jest.fn(),
58
+ };
59
+ mockSourceFs2 = {
60
+ name: jest.fn().mockReturnValue('SourceFs2'),
61
+ create: jest.fn(),
62
+ mkdir: jest.fn(),
63
+ mkdirAll: jest.fn(),
64
+ open: jest.fn().mockResolvedValue(mockFile),
65
+ openFile: jest.fn(),
66
+ remove: jest.fn(),
67
+ removeAll: jest.fn(),
68
+ rename: jest.fn(),
69
+ stat: jest.fn(),
70
+ chmod: jest.fn(),
71
+ chown: jest.fn(),
72
+ chtimes: jest.fn(),
73
+ };
74
+ mockTargetFs = {
75
+ name: jest.fn().mockReturnValue('TargetFs'),
76
+ create: jest.fn().mockResolvedValue(mockFile),
77
+ mkdir: jest.fn(),
78
+ mkdirAll: jest.fn(),
79
+ open: jest.fn().mockResolvedValue(mockFile),
80
+ openFile: jest.fn(),
81
+ remove: jest.fn(),
82
+ removeAll: jest.fn(),
83
+ rename: jest.fn(),
84
+ stat: jest.fn(),
85
+ chmod: jest.fn(),
86
+ chown: jest.fn(),
87
+ chtimes: jest.fn(),
88
+ };
89
+ });
90
+ afterEach(() => {
91
+ jest.clearAllMocks();
92
+ });
93
+ describe('constructor', () => {
94
+ it('should initialize with source and target filesystems', () => {
95
+ staticCopier = new static_copier_1.StaticCopier([mockSourceFs1, mockSourceFs2], mockTargetFs);
96
+ expect(staticCopier).toBeDefined();
97
+ expect(staticCopier.fromFss).toEqual([mockSourceFs1, mockSourceFs2]);
98
+ expect(staticCopier.toFs).toBe(mockTargetFs);
99
+ });
100
+ it('should handle empty source filesystems array', () => {
101
+ staticCopier = new static_copier_1.StaticCopier([], mockTargetFs);
102
+ expect(staticCopier.fromFss).toEqual([]);
103
+ expect(staticCopier.toFs).toBe(mockTargetFs);
104
+ });
105
+ });
106
+ describe('copy', () => {
107
+ beforeEach(() => {
108
+ staticCopier = new static_copier_1.StaticCopier([mockSourceFs1], mockTargetFs);
109
+ });
110
+ it('should return early when no source filesystems', async () => {
111
+ const emptyCopier = new static_copier_1.StaticCopier([], mockTargetFs);
112
+ await emptyCopier.copy();
113
+ // Should not attempt any filesystem operations
114
+ expect(mockSourceFs1.open).not.toHaveBeenCalled();
115
+ expect(mockTargetFs.open).not.toHaveBeenCalled();
116
+ });
117
+ it('should return early when no target filesystem', async () => {
118
+ const noTargetCopier = new static_copier_1.StaticCopier([mockSourceFs1], null);
119
+ await noTargetCopier.copy();
120
+ // Should not attempt any filesystem operations
121
+ expect(mockSourceFs1.open).not.toHaveBeenCalled();
122
+ });
123
+ it('should copy files from source to target filesystem', async () => {
124
+ // Mock directory structure
125
+ const mockDirInfo = {
126
+ ...mockFileInfo,
127
+ name: jest.fn().mockReturnValue(''),
128
+ isDir: jest.fn().mockReturnValue(true),
129
+ };
130
+ const mockDirFile = {
131
+ ...mockFile,
132
+ stat: jest.fn().mockResolvedValue(mockDirInfo),
133
+ readdir: jest.fn().mockResolvedValue([mockFileInfo]),
134
+ };
135
+ const mockSourceFile = {
136
+ ...mockFile,
137
+ read: jest.fn().mockResolvedValue({ bytesRead: 100, buffer: Buffer.from('test content') }),
138
+ };
139
+ const mockTargetFile = {
140
+ ...mockFile,
141
+ write: jest.fn().mockResolvedValue({ bytesWritten: 100, buffer: Buffer.from('test content') }),
142
+ };
143
+ mockSourceFs1.open
144
+ .mockResolvedValueOnce(mockDirFile) // Root directory
145
+ .mockResolvedValueOnce(mockSourceFile); // Source file
146
+ mockTargetFs.open.mockResolvedValue(mockTargetFile);
147
+ await staticCopier.copy();
148
+ expect(mockSourceFs1.open).toHaveBeenCalledWith('/');
149
+ expect(mockTargetFs.create).toHaveBeenCalled();
150
+ });
151
+ it('should handle filesystem errors gracefully', async () => {
152
+ mockSourceFs1.open.mockRejectedValue(new Error('Filesystem error'));
153
+ // Should not throw, but should log error and continue
154
+ await expect(staticCopier.copy()).resolves.not.toThrow();
155
+ });
156
+ it('should copy from multiple source filesystems', async () => {
157
+ const multiSourceCopier = new static_copier_1.StaticCopier([mockSourceFs1, mockSourceFs2], mockTargetFs);
158
+ // Mock simple file structure for both sources
159
+ const mockDirInfo = {
160
+ ...mockFileInfo,
161
+ isDir: jest.fn().mockReturnValue(true),
162
+ };
163
+ const mockDirFile = {
164
+ ...mockFile,
165
+ stat: jest.fn().mockResolvedValue(mockDirInfo),
166
+ readdir: jest.fn().mockResolvedValue([]),
167
+ };
168
+ mockSourceFs1.open.mockResolvedValue(mockDirFile);
169
+ mockSourceFs2.open.mockResolvedValue(mockDirFile);
170
+ await multiSourceCopier.copy();
171
+ expect(mockSourceFs1.open).toHaveBeenCalledWith('/');
172
+ expect(mockSourceFs2.open).toHaveBeenCalledWith('/');
173
+ });
174
+ });
175
+ describe('copyFile', () => {
176
+ beforeEach(() => {
177
+ staticCopier = new static_copier_1.StaticCopier([mockSourceFs1], mockTargetFs);
178
+ });
179
+ it('should copy file content from source to target', async () => {
180
+ const sourceContent = Buffer.from('Hello, World!');
181
+ const mockSourceFile = {
182
+ ...mockFile,
183
+ read: jest.fn()
184
+ .mockResolvedValueOnce({ bytesRead: sourceContent.length, buffer: sourceContent })
185
+ .mockResolvedValueOnce({ bytesRead: 0, buffer: Buffer.alloc(0) }), // EOF
186
+ };
187
+ const mockTargetFile = {
188
+ ...mockFile,
189
+ write: jest.fn().mockResolvedValue({ bytesWritten: sourceContent.length, buffer: sourceContent }),
190
+ };
191
+ mockSourceFs1.open.mockResolvedValue(mockSourceFile);
192
+ mockTargetFs.create.mockResolvedValue(mockTargetFile);
193
+ await staticCopier.copyFile(mockSourceFs1, '/test.txt', mockTargetFs, '/target');
194
+ expect(mockSourceFs1.open).toHaveBeenCalledWith('/test.txt');
195
+ expect(mockTargetFs.create).toHaveBeenCalledWith('/target/test.txt');
196
+ expect(mockSourceFile.read).toHaveBeenCalled();
197
+ // Check that write was called - implementation may pass array or buffer
198
+ expect(mockTargetFile.write).toHaveBeenCalled();
199
+ const writeCall = mockTargetFile.write.mock.calls[0][0];
200
+ expect(writeCall).toBeDefined();
201
+ // NOTE: Current implementation passes Uint8Array instead of Buffer
202
+ });
203
+ it('should handle file read errors gracefully', async () => {
204
+ mockSourceFs1.open.mockRejectedValue(new Error('Cannot read file'));
205
+ // Should not throw, but should log error and continue
206
+ await expect(staticCopier.copyFile(mockSourceFs1, '/test.txt', mockTargetFs, '/target')).resolves.not.toThrow();
207
+ });
208
+ it('should handle file write errors gracefully', async () => {
209
+ const mockSourceFile = {
210
+ ...mockFile,
211
+ read: jest.fn().mockResolvedValue({ bytesRead: 10, buffer: Buffer.from('test') }),
212
+ };
213
+ mockSourceFs1.open.mockResolvedValue(mockSourceFile);
214
+ mockTargetFs.create.mockRejectedValue(new Error('Cannot write file'));
215
+ // Should not throw, but should log error and continue
216
+ await expect(staticCopier.copyFile(mockSourceFs1, '/test.txt', mockTargetFs, '/target')).resolves.not.toThrow();
217
+ });
218
+ });
219
+ describe('walkFileSystem', () => {
220
+ beforeEach(() => {
221
+ staticCopier = new static_copier_1.StaticCopier([mockSourceFs1], mockTargetFs);
222
+ });
223
+ it('should handle single file', async () => {
224
+ const callback = jest.fn();
225
+ mockFile.stat.mockResolvedValue(mockFileInfo);
226
+ await staticCopier.walkFileSystem(mockSourceFs1, '/test.txt', callback);
227
+ expect(callback).toHaveBeenCalledWith('/test.txt', false);
228
+ expect(mockFile.close).toHaveBeenCalled();
229
+ });
230
+ it('should handle directory with files', async () => {
231
+ const callback = jest.fn();
232
+ const mockDirInfo = {
233
+ ...mockFileInfo,
234
+ isDir: jest.fn().mockReturnValue(true),
235
+ };
236
+ const mockChildFile = {
237
+ name: jest.fn().mockReturnValue('child.txt'),
238
+ isDir: jest.fn().mockReturnValue(false),
239
+ };
240
+ const mockDirFile = {
241
+ ...mockFile,
242
+ stat: jest.fn().mockResolvedValue(mockDirInfo),
243
+ readdir: jest.fn().mockResolvedValue([mockChildFile]),
244
+ };
245
+ const mockChildFileHandle = {
246
+ ...mockFile,
247
+ stat: jest.fn().mockResolvedValue(mockChildFile),
248
+ };
249
+ mockSourceFs1.open
250
+ .mockResolvedValueOnce(mockDirFile) // Directory
251
+ .mockResolvedValueOnce(mockChildFileHandle); // Child file
252
+ await staticCopier.walkFileSystem(mockSourceFs1, '/testdir', callback);
253
+ expect(callback).toHaveBeenCalledWith('/testdir/child.txt', false);
254
+ });
255
+ it('should handle nested directories', async () => {
256
+ const callback = jest.fn();
257
+ const mockDirInfo = {
258
+ ...mockFileInfo,
259
+ isDir: jest.fn().mockReturnValue(true),
260
+ };
261
+ const mockSubDirInfo = {
262
+ name: jest.fn().mockReturnValue('subdir'),
263
+ isDir: jest.fn().mockReturnValue(true),
264
+ };
265
+ const mockDirFile = {
266
+ ...mockFile,
267
+ stat: jest.fn().mockResolvedValue(mockDirInfo),
268
+ readdir: jest.fn().mockResolvedValue([mockSubDirInfo]),
269
+ };
270
+ const mockSubDirFile = {
271
+ ...mockFile,
272
+ stat: jest.fn().mockResolvedValue(mockSubDirInfo),
273
+ readdir: jest.fn().mockResolvedValue([]),
274
+ };
275
+ mockSourceFs1.open
276
+ .mockResolvedValueOnce(mockDirFile) // Root directory
277
+ .mockResolvedValueOnce(mockSubDirFile); // Subdirectory
278
+ await staticCopier.walkFileSystem(mockSourceFs1, '/testdir', callback);
279
+ expect(mockSourceFs1.open).toHaveBeenCalledWith('/testdir');
280
+ expect(mockSourceFs1.open).toHaveBeenCalledWith('/testdir/subdir');
281
+ });
282
+ it('should handle filesystem errors during walk gracefully', async () => {
283
+ const callback = jest.fn();
284
+ mockSourceFs1.open.mockRejectedValue(new Error('Cannot access path'));
285
+ // Should not throw, but should log error and continue
286
+ await expect(staticCopier.walkFileSystem(mockSourceFs1, '/nonexistent', callback)).resolves.not.toThrow();
287
+ });
288
+ });
289
+ describe('edge cases', () => {
290
+ it('should handle null source filesystems', async () => {
291
+ const nullSourceCopier = new static_copier_1.StaticCopier(null, mockTargetFs);
292
+ await nullSourceCopier.copy();
293
+ // Should not crash and not attempt operations
294
+ expect(mockTargetFs.open).not.toHaveBeenCalled();
295
+ });
296
+ it('should handle undefined target filesystem', async () => {
297
+ const undefinedTargetCopier = new static_copier_1.StaticCopier([mockSourceFs1], undefined);
298
+ await undefinedTargetCopier.copy();
299
+ // Should not crash and not attempt operations
300
+ expect(mockSourceFs1.open).not.toHaveBeenCalled();
301
+ });
302
+ it('should handle empty directory', async () => {
303
+ const callback = jest.fn();
304
+ const mockDirInfo = {
305
+ ...mockFileInfo,
306
+ isDir: jest.fn().mockReturnValue(true),
307
+ };
308
+ const mockDirFile = {
309
+ ...mockFile,
310
+ stat: jest.fn().mockResolvedValue(mockDirInfo),
311
+ readdir: jest.fn().mockResolvedValue([]),
312
+ };
313
+ mockSourceFs1.open.mockResolvedValue(mockDirFile);
314
+ await staticCopier.walkFileSystem(mockSourceFs1, '/empty', callback);
315
+ expect(callback).not.toHaveBeenCalled(); // No files to process
316
+ expect(mockDirFile.close).toHaveBeenCalled();
317
+ });
318
+ });
319
+ });
320
+ //# sourceMappingURL=vo-static-copier.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vo-static-copier.test.js","sourceRoot":"","sources":["../../../../../internal/domain/fs/tests/vo-static-copier.test.ts"],"names":[],"mappings":";;AAAA,uDAAmD;AAGnD,oBAAoB;AACpB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3B,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;QACtB,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QACf,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;QAChB,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;KAChB,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,aAA8B,CAAC;IACnC,IAAI,aAA8B,CAAC;IACnC,IAAI,YAA6B,CAAC;IAClC,IAAI,QAA2B,CAAC;IAChC,IAAI,YAAmC,CAAC;IACxC,IAAI,YAA0B,CAAC;IAE/B,UAAU,CAAC,GAAG,EAAE;QACd,YAAY,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC;YAC3C,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC;YACpC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;YACtC,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,IAAI,EAAE,CAAC;YAC9C,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;YACvC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;SACrC,CAAC;QAEF,QAAQ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WAAW,GAAG;gBAClB,GAAG,QAAQ;gBACX,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC;gBAC9C,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC;aACzC,CAAC;YAEF,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,WAAkB,CAAC,CAAC;YAEzD,MAAO,YAAoB,CAAC,cAAc,CAAC,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAE9E,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,sBAAsB;YAC/D,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=vo-walkway.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vo-walkway.test.d.ts","sourceRoot":"","sources":["../../../../../internal/domain/fs/tests/vo-walkway.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const walkway_1 = require("../vo/walkway");
4
+ const type_1 = require("../type");
5
+ // Mock dependencies
6
+ jest.mock('@pkg/log', () => ({
7
+ getDomainLogger: () => ({
8
+ error: jest.fn(),
9
+ info: jest.fn(),
10
+ debug: jest.fn(),
11
+ }),
12
+ }));
13
+ jest.mock('../vo/fileinfo', () => ({
14
+ newFileInfoWithMeta: jest.fn().mockImplementation((fileInfo, meta) => ({
15
+ ...fileInfo,
16
+ fileName: meta.fileName,
17
+ relativeFilename: meta.relativeFilename,
18
+ component: meta.component,
19
+ root: meta.root,
20
+ open: meta.open,
21
+ })),
22
+ }));
23
+ jest.mock('../vo/filemeta', () => ({
24
+ newFileMeta: jest.fn().mockImplementation((filename) => ({
25
+ fileName: jest.fn().mockReturnValue(filename),
26
+ relativeFilename: jest.fn().mockReturnValue(filename),
27
+ component: jest.fn().mockReturnValue(''),
28
+ root: jest.fn().mockReturnValue(''),
29
+ open: jest.fn(),
30
+ setOpenFunc: jest.fn(),
31
+ })),
32
+ }));
33
+ describe('Walkway Value Object', () => {
34
+ let mockFs;
35
+ let mockWalkCallback;
36
+ let mockWalkFn;
37
+ let walkway;
38
+ beforeEach(() => {
39
+ mockWalkFn = jest.fn();
40
+ mockWalkCallback = {
41
+ walkFn: mockWalkFn,
42
+ };
43
+ mockFs = {
44
+ name: jest.fn().mockReturnValue('MockFs'),
45
+ create: jest.fn(),
46
+ mkdir: jest.fn(),
47
+ mkdirAll: jest.fn(),
48
+ open: jest.fn(),
49
+ openFile: jest.fn(),
50
+ remove: jest.fn(),
51
+ removeAll: jest.fn(),
52
+ rename: jest.fn(),
53
+ stat: jest.fn(),
54
+ chmod: jest.fn(),
55
+ chown: jest.fn(),
56
+ chtimes: jest.fn(),
57
+ };
58
+ });
59
+ afterEach(() => {
60
+ jest.clearAllMocks();
61
+ });
62
+ describe('constructor', () => {
63
+ it('should initialize with filesystem and callback', () => {
64
+ walkway = new walkway_1.Walkway(mockFs, mockWalkCallback);
65
+ expect(walkway).toBeDefined();
66
+ expect(walkway.fs).toBe(mockFs);
67
+ expect(walkway.cb).toBe(mockWalkCallback);
68
+ expect(walkway.root).toBe('');
69
+ expect(walkway.walked).toBe(false);
70
+ });
71
+ it('should throw error when fs is not provided', () => {
72
+ expect(() => new walkway_1.Walkway(null, mockWalkCallback)).toThrow('fs must be set');
73
+ });
74
+ it('should throw error when walkFn is not provided', () => {
75
+ const invalidCallback = {};
76
+ expect(() => new walkway_1.Walkway(mockFs, invalidCallback)).toThrow('walkFn must be set');
77
+ });
78
+ it('should throw error when callback is not provided', () => {
79
+ expect(() => new walkway_1.Walkway(mockFs, null)).toThrow('Cannot read properties of null');
80
+ });
81
+ });
82
+ describe('walkWith', () => {
83
+ beforeEach(() => {
84
+ walkway = new walkway_1.Walkway(mockFs, mockWalkCallback);
85
+ });
86
+ it('should set root and config before walking', async () => {
87
+ const config = { sortDirEntries: true };
88
+ const mockFileInfo = createMockFileInfo('test.txt', false);
89
+ mockFs.stat.mockResolvedValue(mockFileInfo);
90
+ await walkway.walkWith('/test/root', config);
91
+ expect(walkway.root).toBe('/test/root');
92
+ expect(walkway.cfg).toBe(config);
93
+ expect(mockFs.stat).toHaveBeenCalledWith('/test/root');
94
+ });
95
+ it('should handle empty root path', async () => {
96
+ const mockFileInfo = createMockFileInfo('', true);
97
+ mockFs.stat.mockResolvedValue(mockFileInfo);
98
+ const mockFile = createMockFile([]);
99
+ mockFs.open.mockResolvedValue(mockFile);
100
+ await walkway.walkWith('', {});
101
+ expect(mockFs.stat).toHaveBeenCalledWith('');
102
+ });
103
+ });
104
+ describe('walk', () => {
105
+ beforeEach(() => {
106
+ walkway = new walkway_1.Walkway(mockFs, mockWalkCallback);
107
+ });
108
+ it('should throw error if already walked', async () => {
109
+ const mockFileInfo = createMockFileInfo('test.txt', false);
110
+ mockFs.stat.mockResolvedValue(mockFileInfo);
111
+ // First walk
112
+ await walkway.walkWith('/test', {});
113
+ // Second walk should fail
114
+ await expect(walkway.walk()).rejects.toThrow('this walkway is already walked');
115
+ });
116
+ it('should walk single file', async () => {
117
+ const mockFileInfo = createMockFileInfo('test.txt', false);
118
+ mockFs.stat.mockResolvedValue(mockFileInfo);
119
+ await walkway.walkWith('/test.txt', {});
120
+ expect(mockFs.stat).toHaveBeenCalledWith('/test.txt');
121
+ expect(mockWalkFn).toHaveBeenCalledWith('/test.txt', expect.any(Object));
122
+ });
123
+ it('should walk directory with files', async () => {
124
+ const mockDirInfo = createMockFileInfo('testdir', true);
125
+ const mockFileInfo1 = createMockFileInfo('file1.txt', false);
126
+ const mockFileInfo2 = createMockFileInfo('file2.txt', false);
127
+ mockFs.stat
128
+ .mockResolvedValueOnce(mockDirInfo) // Directory stat
129
+ .mockResolvedValueOnce(mockFileInfo1) // file1.txt stat
130
+ .mockResolvedValueOnce(mockFileInfo2); // file2.txt stat
131
+ const mockFile = createMockFile([mockFileInfo1, mockFileInfo2]);
132
+ mockFs.open.mockResolvedValue(mockFile);
133
+ await walkway.walkWith('/testdir', {});
134
+ expect(mockWalkFn).toHaveBeenCalledTimes(3); // Directory + 2 files
135
+ expect(mockWalkFn).toHaveBeenCalledWith('/testdir', expect.any(Object));
136
+ expect(mockWalkFn).toHaveBeenCalledWith('/testdir/file1.txt', expect.any(Object));
137
+ expect(mockWalkFn).toHaveBeenCalledWith('/testdir/file2.txt', expect.any(Object));
138
+ });
139
+ it('should sort directory entries when configured', async () => {
140
+ const mockDirInfo = createMockFileInfo('testdir', true);
141
+ const mockFileInfo1 = createMockFileInfo('zebra.txt', false);
142
+ const mockFileInfo2 = createMockFileInfo('alpha.txt', false);
143
+ mockFs.stat
144
+ .mockResolvedValueOnce(mockDirInfo)
145
+ .mockResolvedValueOnce(mockFileInfo2) // alpha.txt (sorted first)
146
+ .mockResolvedValueOnce(mockFileInfo1); // zebra.txt (sorted second)
147
+ const mockFile = createMockFile([mockFileInfo1, mockFileInfo2]); // Unsorted order
148
+ mockFs.open.mockResolvedValue(mockFile);
149
+ await walkway.walkWith('/testdir', { sortDirEntries: true });
150
+ expect(mockWalkFn).toHaveBeenCalledWith('/testdir/alpha.txt', expect.any(Object));
151
+ expect(mockWalkFn).toHaveBeenCalledWith('/testdir/zebra.txt', expect.any(Object));
152
+ });
153
+ it('should handle ErrSkipDir for directories', async () => {
154
+ const mockDirInfo = createMockFileInfo('skipdir', true);
155
+ mockFs.stat.mockResolvedValue(mockDirInfo);
156
+ mockWalkFn.mockImplementation((path, info) => {
157
+ if (info.isDir && info.isDir()) {
158
+ throw type_1.ErrSkipDir;
159
+ }
160
+ });
161
+ await walkway.walkWith('/skipdir', {});
162
+ expect(mockWalkFn).toHaveBeenCalledTimes(1);
163
+ expect(mockFs.open).not.toHaveBeenCalled(); // Should not read directory contents
164
+ });
165
+ it('should handle filesystem stat errors', async () => {
166
+ mockFs.stat.mockRejectedValue(new Error('File not found'));
167
+ await expect(walkway.walkWith('/nonexistent', {})).rejects.toThrow('walk: stat: File not found');
168
+ });
169
+ it('should handle filesystem readdir errors', async () => {
170
+ const mockDirInfo = createMockFileInfo('testdir', true);
171
+ mockFs.stat.mockResolvedValue(mockDirInfo);
172
+ mockFs.open.mockRejectedValue(new Error('Cannot read directory'));
173
+ await expect(walkway.walkWith('/testdir', {})).rejects.toThrow('walk: readdir: Cannot read directory');
174
+ });
175
+ it('should handle walkFn errors', async () => {
176
+ const mockFileInfo = createMockFileInfo('test.txt', false);
177
+ mockFs.stat.mockResolvedValue(mockFileInfo);
178
+ mockWalkFn.mockRejectedValue(new Error('Walk function failed'));
179
+ await expect(walkway.walkWith('/test.txt', {})).rejects.toThrow('Walk function failed');
180
+ });
181
+ it('should handle nested directories', async () => {
182
+ const mockRootDir = createMockFileInfo('root', true);
183
+ const mockSubDir = createMockFileInfo('subdir', true);
184
+ const mockFile = createMockFileInfo('file.txt', false);
185
+ mockFs.stat
186
+ .mockResolvedValueOnce(mockRootDir) // /root
187
+ .mockResolvedValueOnce(mockSubDir) // /root/subdir
188
+ .mockResolvedValueOnce(mockFile); // /root/subdir/file.txt
189
+ const mockRootFile = createMockFile([mockSubDir]);
190
+ const mockSubFile = createMockFile([mockFile]);
191
+ const mockLeafFile = createMockFile([]);
192
+ mockFs.open
193
+ .mockResolvedValueOnce(mockRootFile) // Open /root
194
+ .mockResolvedValueOnce(mockSubFile) // Open /root/subdir
195
+ .mockResolvedValueOnce(mockLeafFile); // Open /root/subdir/file.txt (if needed)
196
+ await walkway.walkWith('/root', {});
197
+ expect(mockWalkFn).toHaveBeenCalledTimes(3);
198
+ expect(mockWalkFn).toHaveBeenCalledWith('/root', expect.any(Object));
199
+ expect(mockWalkFn).toHaveBeenCalledWith('/root/subdir', expect.any(Object));
200
+ expect(mockWalkFn).toHaveBeenCalledWith('/root/subdir/file.txt', expect.any(Object));
201
+ });
202
+ });
203
+ describe('error handling', () => {
204
+ beforeEach(() => {
205
+ walkway = new walkway_1.Walkway(mockFs, mockWalkCallback);
206
+ });
207
+ it('should handle checkErr method for specific errors', async () => {
208
+ const mockFileInfo = createMockFileInfo('test.txt', false);
209
+ mockFs.stat.mockResolvedValue(mockFileInfo);
210
+ // Mock checkErr to return true (ignore error)
211
+ jest.spyOn(walkway, 'checkErr').mockReturnValue(true);
212
+ // This should not throw despite the stat error
213
+ mockFs.stat.mockRejectedValueOnce(new Error('Ignored error'));
214
+ // The walk should complete without throwing
215
+ await walkway.walkWith('/test.txt', {});
216
+ });
217
+ it('should handle path joining correctly', () => {
218
+ // Since joinPath is not a public method, we'll test path joining through walkWith
219
+ const mockFileInfo = createMockFileInfo('test.txt', false);
220
+ mockFs.stat.mockResolvedValue(mockFileInfo);
221
+ expect(async () => await walkway.walkWith('/root/file.txt', {})).not.toThrow();
222
+ });
223
+ it('should handle root path joining', () => {
224
+ // Test with root path
225
+ const mockFileInfo = createMockFileInfo('file.txt', false);
226
+ mockFs.stat.mockResolvedValue(mockFileInfo);
227
+ expect(async () => await walkway.walkWith('/', {})).not.toThrow();
228
+ });
229
+ it('should handle empty path components', () => {
230
+ // Test with empty path
231
+ const mockFileInfo = createMockFileInfo('', false);
232
+ mockFs.stat.mockResolvedValue(mockFileInfo);
233
+ expect(async () => await walkway.walkWith('', {})).not.toThrow();
234
+ });
235
+ });
236
+ describe('configuration options', () => {
237
+ beforeEach(() => {
238
+ walkway = new walkway_1.Walkway(mockFs, mockWalkCallback);
239
+ });
240
+ it('should respect sortDirEntries option', async () => {
241
+ const mockDirInfo = createMockFileInfo('testdir', true);
242
+ const entries = [
243
+ createMockFileInfo('c.txt', false),
244
+ createMockFileInfo('a.txt', false),
245
+ createMockFileInfo('b.txt', false),
246
+ ];
247
+ mockFs.stat
248
+ .mockResolvedValueOnce(mockDirInfo)
249
+ .mockResolvedValueOnce(entries[1]) // a.txt
250
+ .mockResolvedValueOnce(entries[2]) // b.txt
251
+ .mockResolvedValueOnce(entries[0]); // c.txt
252
+ const mockFile = createMockFile(entries);
253
+ mockFs.open.mockResolvedValue(mockFile);
254
+ await walkway.walkWith('/testdir', { sortDirEntries: true });
255
+ // Verify the order of calls (after directory itself)
256
+ expect(mockWalkFn).toHaveBeenNthCalledWith(2, '/testdir/a.txt', expect.any(Object));
257
+ expect(mockWalkFn).toHaveBeenNthCalledWith(3, '/testdir/b.txt', expect.any(Object));
258
+ expect(mockWalkFn).toHaveBeenNthCalledWith(4, '/testdir/c.txt', expect.any(Object));
259
+ });
260
+ });
261
+ // Helper functions
262
+ function createMockFileInfo(name, isDir) {
263
+ return {
264
+ name: jest.fn().mockReturnValue(name),
265
+ size: jest.fn().mockReturnValue(isDir ? 0 : 100),
266
+ mode: jest.fn().mockReturnValue(isDir ? 0o755 : 0o644),
267
+ modTime: jest.fn().mockReturnValue(new Date()),
268
+ isDir: jest.fn().mockReturnValue(isDir),
269
+ sys: jest.fn().mockReturnValue(null),
270
+ fileName: jest.fn().mockReturnValue(`/${name}`),
271
+ relativeFilename: jest.fn().mockReturnValue(name),
272
+ component: jest.fn().mockReturnValue(''),
273
+ root: jest.fn().mockReturnValue(''),
274
+ open: jest.fn(),
275
+ };
276
+ }
277
+ function createMockFile(entries) {
278
+ return {
279
+ close: jest.fn(),
280
+ read: jest.fn(),
281
+ readAt: jest.fn(),
282
+ seek: jest.fn(),
283
+ write: jest.fn(),
284
+ writeAt: jest.fn(),
285
+ name: jest.fn(),
286
+ readdir: jest.fn().mockResolvedValue(entries),
287
+ readdirnames: jest.fn(),
288
+ stat: jest.fn(),
289
+ sync: jest.fn(),
290
+ truncate: jest.fn(),
291
+ writeString: jest.fn(),
292
+ };
293
+ }
294
+ });
295
+ //# sourceMappingURL=vo-walkway.test.js.map