11import { describe , expect , it } from "bun:test"
2- import { parseConfig } from "./config.ts"
2+ import { homedir } from "node:os"
3+ import { parseConfig , resolveProjectPath } from "./config.ts"
34
45describe ( "config" , ( ) => {
56 describe ( "parseConfig" , ( ) => {
@@ -12,7 +13,7 @@ describe("config", () => {
1213 expect ( config . autoCapture ) . toBe ( true )
1314 expect ( config . debug ) . toBe ( false )
1415 expect ( config . project ) . toMatch ( / ^ o p e n c l a w - / )
15- expect ( config . projectPath ) . toMatch ( / \. o p e n c l a w \/ w o r k s p a c e \/ m e m o r y \/ / )
16+ expect ( config . projectPath ) . toBe ( " memory/" )
1617 expect ( config . cloud ) . toBeUndefined ( )
1718 } )
1819
@@ -67,6 +68,11 @@ describe("config", () => {
6768 expect ( config . projectPath ) . toBe ( "/custom/project/path" )
6869 } )
6970
71+ it ( "should default projectPath to memoryDir" , ( ) => {
72+ const config = parseConfig ( { memoryDir : "notes/" } )
73+ expect ( config . projectPath ) . toBe ( "notes/" )
74+ } )
75+
7076 it ( "should use provided autoCapture" , ( ) => {
7177 expect ( parseConfig ( { autoCapture : false } ) . autoCapture ) . toBe ( false )
7278 expect ( parseConfig ( { autoCapture : true } ) . autoCapture ) . toBe ( true )
@@ -124,4 +130,24 @@ describe("config", () => {
124130 expect ( ( ) => parseConfig ( { } ) ) . not . toThrow ( )
125131 } )
126132 } )
133+
134+ describe ( "resolveProjectPath" , ( ) => {
135+ it ( "resolves relative projectPath against workspace" , ( ) => {
136+ expect ( resolveProjectPath ( "memory/" , "/tmp/workspace" ) ) . toBe (
137+ "/tmp/workspace/memory" ,
138+ )
139+ } )
140+
141+ it ( "expands tilde paths" , ( ) => {
142+ expect ( resolveProjectPath ( "~/memory" , "/tmp/workspace" ) ) . toBe (
143+ `${ homedir ( ) } /memory` ,
144+ )
145+ } )
146+
147+ it ( "keeps absolute paths unchanged" , ( ) => {
148+ expect ( resolveProjectPath ( "/var/data/memory" , "/tmp/workspace" ) ) . toBe (
149+ "/var/data/memory" ,
150+ )
151+ } )
152+ } )
127153} )
0 commit comments