@@ -5,60 +5,15 @@ import { describe, expect, it } from 'vitest'
55import {
66 isGitHubTgzSpec ,
77 isGitHubUrlSpec ,
8- normalizePackageJson ,
98 readPackageJsonSync ,
109 resolveEscapedScope ,
1110 resolvePackageJsonDirname ,
12- resolvePackageJsonPath ,
1311 resolvePackageName ,
1412 resolveRegistryPackageName ,
1513 unescapeScope ,
1614} from '../../registry/dist/lib/packages.js'
1715
1816describe ( 'packages module - operations and utilities' , ( ) => {
19- describe ( 'normalizePackageJson' , ( ) => {
20- it ( 'should normalize basic package.json' , ( ) => {
21- const pkg = {
22- name : 'test-package' ,
23- version : '1.0.0' ,
24- }
25- const result = normalizePackageJson ( pkg )
26- expect ( result . name ) . toBe ( 'test-package' )
27- expect ( result . version ) . toBe ( '1.0.0' )
28- } )
29-
30- it ( 'should handle package with dependencies' , ( ) => {
31- const pkg = {
32- name : 'test' ,
33- version : '1.0.0' ,
34- dependencies : {
35- lodash : '^4.17.21' ,
36- } ,
37- }
38- const result = normalizePackageJson ( pkg )
39- expect ( result . dependencies ) . toBeDefined ( )
40- } )
41-
42- it ( 'should handle package with scripts' , ( ) => {
43- const pkg = {
44- name : 'test' ,
45- version : '1.0.0' ,
46- scripts : {
47- test : 'vitest' ,
48- build : 'tsc' ,
49- } ,
50- }
51- const result = normalizePackageJson ( pkg )
52- expect ( result [ 'scripts' ] ) . toBeDefined ( )
53- } )
54-
55- it ( 'should handle empty package' , ( ) => {
56- const pkg = { }
57- const result = normalizePackageJson ( pkg )
58- expect ( result ) . toBeDefined ( )
59- } )
60- } )
61-
6217 describe ( 'readPackageJsonSync' , ( ) => {
6318 it ( 'should read package.json from project root' , ( ) => {
6419 const pkgPath = path . join ( process . cwd ( ) , 'package.json' )
@@ -150,28 +105,6 @@ describe('packages module - operations and utilities', () => {
150105 } )
151106 } )
152107
153- describe ( 'resolvePackageJsonPath' , ( ) => {
154- it ( 'should return path if already package.json' , ( ) => {
155- const result = resolvePackageJsonPath ( '/some/path/package.json' )
156- expect ( result ) . toBe ( '/some/path/package.json' )
157- } )
158-
159- it ( 'should append package.json to directory' , ( ) => {
160- const result = resolvePackageJsonPath ( '/some/path' )
161- expect ( result ) . toBe ( '/some/path/package.json' )
162- } )
163-
164- it ( 'should handle root directory' , ( ) => {
165- const result = resolvePackageJsonPath ( '/' )
166- expect ( result ) . toContain ( 'package.json' )
167- } )
168-
169- it ( 'should handle current directory' , ( ) => {
170- const result = resolvePackageJsonPath ( '.' )
171- expect ( result ) . toContain ( 'package.json' )
172- } )
173- } )
174-
175108 describe ( 'resolvePackageJsonDirname' , ( ) => {
176109 it ( 'should extract dirname from package.json path' , ( ) => {
177110 const result = resolvePackageJsonDirname ( '/some/path/package.json' )
0 commit comments