@@ -2,9 +2,18 @@ import { describe, expect, it, vi } from "vitest";
22import { getNamedBackupsEntry } from "../lib/storage/named-backups-entry.js" ;
33
44describe ( "named backups entry" , ( ) => {
5- it ( "passes storage path and dependencies through to named backup collection" , async ( ) => {
6- const collectNamedBackups = vi . fn ( async ( ) => [ ] ) ;
7- const loadAccountsFromPath = vi . fn ( async ( ) => ( { normalized : null } ) ) ;
5+ it ( "delegates to collectNamedBackups with resolved storage path and deps" , async ( ) => {
6+ const collectNamedBackups = vi . fn ( async ( ) => [
7+ {
8+ path : "/tmp/backup.json" ,
9+ fileName : "backup.json" ,
10+ accountCount : 1 ,
11+ mtimeMs : 1 ,
12+ } ,
13+ ] ) ;
14+ const loadAccountsFromPath = vi . fn ( async ( ) => ( {
15+ normalized : { accounts : [ ] } ,
16+ } ) ) ;
817 const logDebug = vi . fn ( ) ;
918
1019 const result = await getNamedBackupsEntry ( {
@@ -18,6 +27,34 @@ describe("named backups entry", () => {
1827 loadAccountsFromPath,
1928 logDebug,
2029 } ) ;
21- expect ( result ) . toEqual ( [ ] ) ;
30+ expect ( result ) . toEqual ( [
31+ {
32+ path : "/tmp/backup.json" ,
33+ fileName : "backup.json" ,
34+ accountCount : 1 ,
35+ mtimeMs : 1 ,
36+ } ,
37+ ] ) ;
38+ } ) ;
39+
40+ it ( "passes through windows-style storage paths unchanged" , async ( ) => {
41+ const windowsStoragePath = "C:\\Users\\dev\\.codex\\accounts.json" ;
42+ const collectNamedBackups = vi . fn ( async ( ) => [ ] ) ;
43+ const loadAccountsFromPath = vi . fn ( async ( ) => ( {
44+ normalized : { accounts : [ ] } ,
45+ } ) ) ;
46+ const logDebug = vi . fn ( ) ;
47+
48+ await getNamedBackupsEntry ( {
49+ getStoragePath : ( ) => windowsStoragePath ,
50+ collectNamedBackups,
51+ loadAccountsFromPath,
52+ logDebug,
53+ } ) ;
54+
55+ expect ( collectNamedBackups ) . toHaveBeenCalledWith ( windowsStoragePath , {
56+ loadAccountsFromPath,
57+ logDebug,
58+ } ) ;
2259 } ) ;
2360} ) ;
0 commit comments