Skip to content

Commit 9b429e3

Browse files
committed
Add test
1 parent d434719 commit 9b429e3

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

componentDetection.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,44 @@ describe("ComponentDetection.processComponentsToManifests", () => {
156156
expect(manifests[0].indirectDependencies()).toHaveLength(1);
157157
expect(manifests[0].countDependencies()).toBe(1);
158158
});
159+
160+
test("un-escapes URL-encoded locationsFoundAt", () => {
161+
const componentsFound = [
162+
{
163+
component: {
164+
name: "test-package",
165+
version: "1.0.0",
166+
packageUrl: {
167+
Scheme: "pkg",
168+
Type: "nuget",
169+
Name: "test-package",
170+
Version: "1.0.0"
171+
},
172+
id: "test-package 1.0.0 - nuget"
173+
},
174+
isDevelopmentDependency: false,
175+
topLevelReferrers: [], // Empty = direct dependency
176+
locationsFoundAt: ["/my%20project/my%20project.csproj"]
177+
}
178+
];
179+
180+
const dependencyGraphs: DependencyGraphs = {
181+
"my project/my project.csproj": {
182+
graph: { "test-package": null },
183+
explicitlyReferencedComponentIds: ["test-package 1.0.0 - nuget"],
184+
developmentDependencies: [],
185+
dependencies: []
186+
}
187+
};
188+
189+
const manifests = ComponentDetection.processComponentsToManifests(componentsFound, dependencyGraphs);
190+
191+
expect(manifests).toHaveLength(1);
192+
expect(manifests[0].name).toBe("my project/my project.csproj");
193+
expect(manifests[0].directDependencies()).toHaveLength(1);
194+
expect(manifests[0].indirectDependencies()).toHaveLength(0);
195+
expect(manifests[0].countDependencies()).toBe(1);
196+
});
159197
});
160198

161199
describe('normalizeDependencyGraphPaths', () => {

0 commit comments

Comments
 (0)