Skip to content

Commit 055c492

Browse files
committed
fix: handle Windows drive letters in path tests and improve regex for multiline timestamps
- Update path-utils.test.ts to handle Windows absolute paths with drive letters - Fix generate-schemas.test.ts regex to match timestamps on separate lines with comment asterisks
1 parent b24cc9a commit 055c492

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/scripts/generate-schemas.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ describe('Schema Generation Script', () => {
9494
expect(content).toContain('*/');
9595
expect(content).toContain('export');
9696
expect(content).toContain('DO NOT EDIT MANUALLY');
97-
// Match timestamp with flexible whitespace/line breaks (handle Windows \r\n)
98-
expect(content).toMatch(
99-
/Generated on:[\s\r\n]*\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/
100-
);
97+
// Match timestamp that may be on the next line after "Generated on:"
98+
expect(content).toMatch(/Generated on:[\s\r\n*]*\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/);
10199
});
102100
});
103101

@@ -263,7 +261,7 @@ describe('Schema Generation Script', () => {
263261
files.forEach((file) => {
264262
const content = readFileSync(join(GENERATED_DIR, file), 'utf8');
265263
const timestampMatch = content.match(
266-
/Generated on:[\s\r\n]*(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)/
264+
/Generated on:[\s\r\n*]*(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)/
267265
);
268266

269267
expect(timestampMatch).toBeTruthy();

src/utils/path-utils.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,16 @@ describe('PathUtils', () => {
139139
const result = PathUtils.findCommonBase(paths);
140140
// Normalize path separators for cross-platform compatibility
141141
const normalizedResult = result.replace(/\\/g, '/');
142-
expect(normalizedResult).toBe('/project');
142+
// On Windows, absolute paths may include drive letters
143+
expect(normalizedResult).toMatch(/^([A-Z]:)?\/project$/);
143144
});
144145

145146
it('should handle single path', () => {
146147
const result = PathUtils.findCommonBase(['/project/docs/file.md']);
147148
// Normalize path separators for cross-platform compatibility
148149
const normalizedResult = result.replace(/\\/g, '/');
149-
expect(normalizedResult).toBe('/project/docs');
150+
// On Windows, absolute paths may include drive letters
151+
expect(normalizedResult).toMatch(/^([A-Z]:)?\/project\/docs$/);
150152
});
151153

152154
it('should handle empty array', () => {

0 commit comments

Comments
 (0)