@@ -11,6 +11,7 @@ import Javascript_pnpm from '../../src/providers/javascript_pnpm.js'
1111import Javascript_yarn from '../../src/providers/javascript_yarn.js'
1212import pythonPipProvider from '../../src/providers/python_pip.js'
1313import rustCargoProvider from '../../src/providers/rust_cargo.js'
14+ import { getCompatibility } from '../../src/license/license_utils.js'
1415import { normalizeLicensesResponse } from '../../src/license/licenses_api.js'
1516
1617suite ( 'normalizeLicensesResponse' , ( ) => {
@@ -62,6 +63,39 @@ suite('normalizeLicensesResponse', () => {
6263 } )
6364} )
6465
66+ suite ( 'getCompatibility with UNKNOWN category' , ( ) => {
67+ /** @type {Array<{proj: string, dep: string, expected: string}> } */
68+ const cases = [
69+ { proj : 'PERMISSIVE' , dep : 'UNKNOWN' , expected : 'incompatible' } ,
70+ { proj : 'WEAK_COPYLEFT' , dep : 'UNKNOWN' , expected : 'incompatible' } ,
71+ { proj : 'STRONG_COPYLEFT' , dep : 'UNKNOWN' , expected : 'incompatible' } ,
72+ { proj : 'UNKNOWN' , dep : 'PERMISSIVE' , expected : 'unknown' } ,
73+ { proj : 'UNKNOWN' , dep : 'UNKNOWN' , expected : 'unknown' } ,
74+ ] ;
75+
76+ cases . forEach ( ( { proj, dep, expected } ) => {
77+ /// Verifies getCompatibility returns the expected result for the given project/dependency category pair.
78+ test ( `getCompatibility('${ proj } ', '${ dep } ') returns '${ expected } '` , ( ) => {
79+ expect ( getCompatibility ( proj , dep ) ) . to . equal ( expected ) ;
80+ } ) ;
81+ } ) ;
82+
83+ /// Verifies that a null project category with UNKNOWN dependency returns 'unknown'.
84+ test ( "getCompatibility(null, 'UNKNOWN') returns 'unknown'" , ( ) => {
85+ expect ( getCompatibility ( null , 'UNKNOWN' ) ) . to . equal ( 'unknown' ) ;
86+ } ) ;
87+
88+ /// Verifies that existing known-category incompatibility checks still work correctly.
89+ test ( "existing incompatibility check: STRONG_COPYLEFT dep vs PERMISSIVE proj returns 'incompatible'" , ( ) => {
90+ expect ( getCompatibility ( 'PERMISSIVE' , 'STRONG_COPYLEFT' ) ) . to . equal ( 'incompatible' ) ;
91+ } ) ;
92+
93+ /// Verifies that compatible known-category checks are unaffected.
94+ test ( "existing compatibility check: PERMISSIVE dep vs STRONG_COPYLEFT proj returns 'compatible'" , ( ) => {
95+ expect ( getCompatibility ( 'STRONG_COPYLEFT' , 'PERMISSIVE' ) ) . to . equal ( 'compatible' ) ;
96+ } ) ;
97+ } ) ;
98+
6599suite ( 'testing readLicenseFromManifest with existing test manifests' , ( ) => {
66100
67101 suite ( 'Java Maven provider' , ( ) => {
0 commit comments