11import * as assert from 'assert' ;
2- import { purlNameKey } from '../enrich/enrich' ;
2+ import { describe , it } from 'node:test' ;
3+ import { purlNameKey } from '../utils' ;
34import { Lockfile } from '../packageJson/lockfile' ;
45import { cleanRange } from '../packageJson/resolveVersion' ;
56import { countTransitive } from '../packageJson/transitive' ;
67
7- suite ( 'countTransitive' , ( ) => {
8+ describe ( 'countTransitive' , ( ) => {
89 const lock : Lockfile = {
910 dir : '/x' ,
1011 lockfileVersion : 3 ,
@@ -18,12 +19,12 @@ suite('countTransitive', () => {
1819 } ,
1920 } ;
2021
21- test ( 'counts unique transitive deps and ignores unrelated packages' , ( ) => {
22+ it ( 'counts unique transitive deps and ignores unrelated packages' , ( ) => {
2223 // a -> b, c ; b -> c. Nested d is not in a's manifest deps, standalone unreachable.
2324 assert . strictEqual ( countTransitive ( lock , 'a' ) , 2 ) ;
2425 } ) ;
2526
26- test ( 'prefers the nested copy when resolving' , ( ) => {
27+ it ( 'prefers the nested copy when resolving' , ( ) => {
2728 const nested : Lockfile = {
2829 dir : '/x' ,
2930 lockfileVersion : 3 ,
@@ -39,41 +40,41 @@ suite('countTransitive', () => {
3940 assert . strictEqual ( countTransitive ( nested , 'a' ) , 2 ) ;
4041 } ) ;
4142
42- test ( 'returns undefined for missing package or non-v2/v3 lockfile' , ( ) => {
43+ it ( 'returns undefined for missing package or non-v2/v3 lockfile' , ( ) => {
4344 assert . strictEqual ( countTransitive ( lock , 'missing' ) , undefined ) ;
4445 assert . strictEqual ( countTransitive ( { dir : '/x' , lockfileVersion : 1 , dependencies : { } } , 'a' ) , undefined ) ;
4546 assert . strictEqual ( countTransitive ( undefined , 'a' ) , undefined ) ;
4647 } ) ;
4748} ) ;
4849
49- suite ( 'cleanRange' , ( ) => {
50- test ( 'extracts a concrete version from a range' , ( ) => {
50+ describe ( 'cleanRange' , ( ) => {
51+ it ( 'extracts a concrete version from a range' , ( ) => {
5152 assert . strictEqual ( cleanRange ( '^4.17.21' ) , '4.17.21' ) ;
5253 assert . strictEqual ( cleanRange ( '~1.2.3' ) , '1.2.3' ) ;
5354 assert . strictEqual ( cleanRange ( '>=1.0.0 <2.0.0' ) , '1.0.0' ) ;
5455 assert . strictEqual ( cleanRange ( '1.2.3-beta.1' ) , '1.2.3-beta.1' ) ;
5556 } ) ;
5657
57- test ( 'returns undefined for non-concrete specs' , ( ) => {
58+ it ( 'returns undefined for non-concrete specs' , ( ) => {
5859 assert . strictEqual ( cleanRange ( '*' ) , undefined ) ;
5960 assert . strictEqual ( cleanRange ( 'latest' ) , undefined ) ;
6061 assert . strictEqual ( cleanRange ( 'workspace:*' ) , undefined ) ;
6162 assert . strictEqual ( cleanRange ( '1.2.x' ) , undefined ) ;
6263 } ) ;
6364} ) ;
6465
65- suite ( 'purlNameKey' , ( ) => {
66- test ( 'collapses backend %40 and literal @ scoped purls to the same key' , ( ) => {
66+ describe ( 'purlNameKey' , ( ) => {
67+ it ( 'collapses backend %40 and literal @ scoped purls to the same key' , ( ) => {
6768 assert . strictEqual ( purlNameKey ( 'pkg:npm/%40sentry/nextjs@8.0.0' ) , 'pkg:npm/@sentry/nextjs' ) ;
6869 assert . strictEqual ( purlNameKey ( 'pkg:npm/@sentry/nextjs@8.0.0' ) , 'pkg:npm/@sentry/nextjs' ) ;
6970 } ) ;
7071
71- test ( 'strips version and qualifiers for unscoped purls' , ( ) => {
72+ it ( 'strips version and qualifiers for unscoped purls' , ( ) => {
7273 assert . strictEqual ( purlNameKey ( 'pkg:npm/next@14.2.0' ) , 'pkg:npm/next' ) ;
7374 assert . strictEqual ( purlNameKey ( 'pkg:npm/next@14.2.0?type=module' ) , 'pkg:npm/next' ) ;
7475 } ) ;
7576
76- test ( 'keeps the name when there is no version' , ( ) => {
77+ it ( 'keeps the name when there is no version' , ( ) => {
7778 assert . strictEqual ( purlNameKey ( 'pkg:npm/%40scope/name' ) , 'pkg:npm/@scope/name' ) ;
7879 assert . strictEqual ( purlNameKey ( 'pkg:npm/next' ) , 'pkg:npm/next' ) ;
7980 } ) ;
0 commit comments