Add nested dirs to test
This commit is contained in:
@@ -198,12 +198,18 @@ describe('normalizeDependencyGraphPaths with real output.json', () => {
|
|||||||
const dependencyGraphs = output.dependencyGraphs;
|
const dependencyGraphs = output.dependencyGraphs;
|
||||||
// Use the same filePath as the action default (".")
|
// Use the same filePath as the action default (".")
|
||||||
const normalized = ComponentDetection.normalizeDependencyGraphPaths(dependencyGraphs, 'test');
|
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.json');
|
||||||
expect(Object.keys(normalized)).toContain('package-lock.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)) {
|
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
|
expect(key).not.toMatch(/^\w:\\|^\/\/|^\.{1,2}\//); // Not windows absolute, not network, not relative
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Generated
+45
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"name": "nested-test-package",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "nested-test-package",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": "^4.17.21"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"jest": "^29.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lodash": {
|
||||||
|
"version": "4.17.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
|
},
|
||||||
|
"node_modules/jest": {
|
||||||
|
"version": "29.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
|
||||||
|
"integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"jest": "bin/jest.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": {
|
||||||
|
"version": "4.17.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"version": "29.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz",
|
||||||
|
"integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "nested-test-package",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A nested test package for component detection testing",
|
||||||
|
"main": "index.js",
|
||||||
|
"dependencies": {
|
||||||
|
"lodash": "^4.17.21"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"jest": "^29.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user