Add nested dirs to test

This commit is contained in:
Lewis Jones
2025-07-09 11:56:34 +01:00
parent 5789c204e4
commit 7d147e8b5f
3 changed files with 66 additions and 3 deletions
+9 -3
View File
@@ -198,12 +198,18 @@ describe('normalizeDependencyGraphPaths with real output.json', () => {
const dependencyGraphs = output.dependencyGraphs;
// Use the same filePath as the action default (".")
const normalized = ComponentDetection.normalizeDependencyGraphPaths(dependencyGraphs, 'test');
// Root level manifests should not have leading slashes
// Should contain root level manifests without leading slashes
expect(Object.keys(normalized)).toContain('package.json');
expect(Object.keys(normalized)).toContain('package-lock.json');
// All keys should now be relative to the repo root (cwd) and start with '/'
// Should contain nested manifests with relative paths (no leading slashes)
expect(Object.keys(normalized)).toContain('nested/package.json');
expect(Object.keys(normalized)).toContain('nested/package-lock.json');
// All keys should be relative paths without leading slashes
for (const key of Object.keys(normalized)) {
expect(key.startsWith('/')).toBe(true);
expect(key.startsWith('/')).toBe(false); // No leading slashes
expect(key).not.toMatch(/^\w:\\|^\/\/|^\.{1,2}\//); // Not windows absolute, not network, not relative
}
});