@@ -3,6 +3,7 @@ import path from 'node:path'
33
44import { describe , expect , it } from 'vitest'
55
6+ import { normalizePath } from '../../registry/dist/lib/path.js'
67import {
78 getSocketAppCacheDir ,
89 getSocketAppCacheTtlDir ,
@@ -19,7 +20,7 @@ describe('paths module', () => {
1920 describe ( 'getSocketUserDir' , ( ) => {
2021 it ( 'should return ~/.socket path' , ( ) => {
2122 const result = getSocketUserDir ( )
22- expect ( result ) . toBe ( path . join ( os . homedir ( ) , '.socket' ) )
23+ expect ( result ) . toBe ( normalizePath ( path . join ( os . homedir ( ) , '.socket' ) ) )
2324 } )
2425
2526 it ( 'should return consistent path on multiple calls' , ( ) => {
@@ -32,45 +33,57 @@ describe('paths module', () => {
3233 describe ( 'getSocketAppDir' , ( ) => {
3334 it ( 'should return app directory with underscore prefix' , ( ) => {
3435 const result = getSocketAppDir ( 'test' )
35- expect ( result ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_test' ) )
36+ expect ( result ) . toBe (
37+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_test' ) ) ,
38+ )
3639 } )
3740
3841 it ( 'should handle different app names' , ( ) => {
3942 const socket = getSocketAppDir ( 'socket' )
4043 const registry = getSocketAppDir ( 'registry' )
41- expect ( socket ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_socket' ) )
42- expect ( registry ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_registry' ) )
44+ expect ( socket ) . toBe (
45+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_socket' ) ) ,
46+ )
47+ expect ( registry ) . toBe (
48+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_registry' ) ) ,
49+ )
4350 } )
4451 } )
4552
4653 describe ( 'getSocketCacacheDir' , ( ) => {
4754 it ( 'should return cacache directory' , ( ) => {
4855 const result = getSocketCacacheDir ( )
49- expect ( result ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_cacache' ) )
56+ expect ( result ) . toBe (
57+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_cacache' ) ) ,
58+ )
5059 } )
5160 } )
5261
5362 describe ( 'getSocketDlxDir' , ( ) => {
5463 it ( 'should return dlx directory' , ( ) => {
5564 const result = getSocketDlxDir ( )
56- expect ( result ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_dlx' ) )
65+ expect ( result ) . toBe (
66+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_dlx' ) ) ,
67+ )
5768 } )
5869 } )
5970
6071 describe ( 'getSocketAppCacheDir' , ( ) => {
6172 it ( 'should return app cache directory' , ( ) => {
6273 const result = getSocketAppCacheDir ( 'test' )
63- expect ( result ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_test' , 'cache' ) )
74+ expect ( result ) . toBe (
75+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_test' , 'cache' ) ) ,
76+ )
6477 } )
6578
6679 it ( 'should handle different app names' , ( ) => {
6780 const socketCache = getSocketAppCacheDir ( 'socket' )
6881 const registryCache = getSocketAppCacheDir ( 'registry' )
6982 expect ( socketCache ) . toBe (
70- path . join ( os . homedir ( ) , '.socket' , '_socket' , 'cache' ) ,
83+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_socket' , 'cache' ) ) ,
7184 )
7285 expect ( registryCache ) . toBe (
73- path . join ( os . homedir ( ) , '.socket' , '_registry' , 'cache' ) ,
86+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_registry' , 'cache' ) ) ,
7487 )
7588 } )
7689 } )
@@ -79,47 +92,59 @@ describe('paths module', () => {
7992 it ( 'should return app TTL cache directory' , ( ) => {
8093 const result = getSocketAppCacheTtlDir ( 'test' )
8194 expect ( result ) . toBe (
82- path . join ( os . homedir ( ) , '.socket' , '_test' , 'cache' , 'ttl' ) ,
95+ normalizePath (
96+ path . join ( os . homedir ( ) , '.socket' , '_test' , 'cache' , 'ttl' ) ,
97+ ) ,
8398 )
8499 } )
85100
86101 it ( 'should handle different app names' , ( ) => {
87102 const socketTtl = getSocketAppCacheTtlDir ( 'socket' )
88103 const registryTtl = getSocketAppCacheTtlDir ( 'registry' )
89104 expect ( socketTtl ) . toBe (
90- path . join ( os . homedir ( ) , '.socket' , '_socket' , 'cache' , 'ttl' ) ,
105+ normalizePath (
106+ path . join ( os . homedir ( ) , '.socket' , '_socket' , 'cache' , 'ttl' ) ,
107+ ) ,
91108 )
92109 expect ( registryTtl ) . toBe (
93- path . join ( os . homedir ( ) , '.socket' , '_registry' , 'cache' , 'ttl' ) ,
110+ normalizePath (
111+ path . join ( os . homedir ( ) , '.socket' , '_registry' , 'cache' , 'ttl' ) ,
112+ ) ,
94113 )
95114 } )
96115 } )
97116
98117 describe ( 'getSocketCliDir' , ( ) => {
99118 it ( 'should return CLI directory' , ( ) => {
100119 const result = getSocketCliDir ( )
101- expect ( result ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_socket' ) )
120+ expect ( result ) . toBe (
121+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_socket' ) ) ,
122+ )
102123 } )
103124 } )
104125
105126 describe ( 'getSocketRegistryDir' , ( ) => {
106127 it ( 'should return Registry directory' , ( ) => {
107128 const result = getSocketRegistryDir ( )
108- expect ( result ) . toBe ( path . join ( os . homedir ( ) , '.socket' , '_registry' ) )
129+ expect ( result ) . toBe (
130+ normalizePath ( path . join ( os . homedir ( ) , '.socket' , '_registry' ) ) ,
131+ )
109132 } )
110133 } )
111134
112135 describe ( 'getSocketRegistryGithubCacheDir' , ( ) => {
113136 it ( 'should return Registry GitHub cache directory' , ( ) => {
114137 const result = getSocketRegistryGithubCacheDir ( )
115138 expect ( result ) . toBe (
116- path . join (
117- os . homedir ( ) ,
118- '.socket' ,
119- '_registry' ,
120- 'cache' ,
121- 'ttl' ,
122- 'github' ,
139+ normalizePath (
140+ path . join (
141+ os . homedir ( ) ,
142+ '.socket' ,
143+ '_registry' ,
144+ 'cache' ,
145+ 'ttl' ,
146+ 'github' ,
147+ ) ,
123148 ) ,
124149 )
125150 } )
@@ -158,14 +183,14 @@ describe('paths module', () => {
158183 } )
159184
160185 describe ( 'platform compatibility' , ( ) => {
161- it ( 'should use correct path separators ' , ( ) => {
186+ it ( 'should use normalized forward slashes ' , ( ) => {
162187 const result = getSocketAppDir ( 'test' )
163- expect ( result . includes ( path . sep ) ) . toBe ( true )
188+ expect ( result . includes ( '/' ) ) . toBe ( true )
164189 } )
165190
166- it ( 'should not contain hardcoded slashes ' , ( ) => {
191+ it ( 'should normalize paths correctly ' , ( ) => {
167192 const result = getSocketUserDir ( )
168- const parts = result . split ( path . sep )
193+ const parts = result . split ( '/' )
169194 expect ( parts [ parts . length - 1 ] ) . toBe ( '.socket' )
170195 } )
171196 } )
0 commit comments