-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show all possible ancestor dependency paths for a package
- Loading branch information
1 parent
c92066e
commit 8f45569
Showing
6 changed files
with
1,430 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as fs from 'fs'; | ||
|
||
import { expect } from '@jest/globals'; | ||
|
||
import { getPackageAncestorPaths, IDocument } from './IDocument'; | ||
|
||
describe('getPackageAncestorPaths', () => { | ||
const document = JSON.parse(fs.readFileSync('tests/spdx/manifest.spdx.json', 'utf-8')) as IDocument; | ||
|
||
it('should return an empty array if the package is not found', () => { | ||
const result = getPackageAncestorPaths(document, 'SPDXRef-NonExistentPackage'); | ||
expect(result).toEqual([]); | ||
}); | ||
|
||
it('should return an empty array if the package has no ancestors', () => { | ||
const result = getPackageAncestorPaths(document, 'SPDXRef-RootPackage'); | ||
expect(result).toEqual([]); | ||
}); | ||
|
||
it('should return the correct dependency path for a package with ancestors', () => { | ||
const targetPackage = document.packages.find((p) => p.name === 'Microsoft.Identity.Web')?.SPDXID || ''; | ||
const result = getPackageAncestorPaths(document, targetPackage); | ||
expect(result).toMatchObject([ | ||
{ dependencyPath: [{ name: 'Microsoft.Identity.Web.UI' }, { name: 'Microsoft.Identity.Web' }] }, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.