@@ -41,64 +41,54 @@ describe("registerBackupCommand", () => {
4141 backupVerifyCommand . mockResolvedValue ( undefined ) ;
4242 } ) ;
4343
44+ function expectForwardedOptions ( command : typeof backupCreateCommand ) : Record < string , unknown > {
45+ expect ( command ) . toHaveBeenCalledTimes ( 1 ) ;
46+ const [ runtimeArg , options ] = command . mock . calls [ 0 ] as unknown as [
47+ typeof runtime ,
48+ Record < string , unknown > ,
49+ ] ;
50+ expect ( runtimeArg ) . toBe ( runtime ) ;
51+ return options ;
52+ }
53+
4454 it ( "runs backup create with forwarded options" , async ( ) => {
4555 await runCli ( [ "backup" , "create" , "--output" , "/tmp/backups" , "--json" , "--dry-run" ] ) ;
4656
47- expect ( backupCreateCommand ) . toHaveBeenCalledWith (
48- runtime ,
49- expect . objectContaining ( {
50- output : "/tmp/backups" ,
51- json : true ,
52- dryRun : true ,
53- verify : false ,
54- onlyConfig : false ,
55- includeWorkspace : true ,
56- } ) ,
57- ) ;
57+ const options = expectForwardedOptions ( backupCreateCommand ) ;
58+ expect ( options . output ) . toBe ( "/tmp/backups" ) ;
59+ expect ( options . json ) . toBe ( true ) ;
60+ expect ( options . dryRun ) . toBe ( true ) ;
61+ expect ( options . verify ) . toBe ( false ) ;
62+ expect ( options . onlyConfig ) . toBe ( false ) ;
63+ expect ( options . includeWorkspace ) . toBe ( true ) ;
5864 } ) ;
5965
6066 it ( "honors --no-include-workspace" , async ( ) => {
6167 await runCli ( [ "backup" , "create" , "--no-include-workspace" ] ) ;
6268
63- expect ( backupCreateCommand ) . toHaveBeenCalledWith (
64- runtime ,
65- expect . objectContaining ( {
66- includeWorkspace : false ,
67- } ) ,
68- ) ;
69+ const options = expectForwardedOptions ( backupCreateCommand ) ;
70+ expect ( options . includeWorkspace ) . toBe ( false ) ;
6971 } ) ;
7072
7173 it ( "forwards --verify to backup create" , async ( ) => {
7274 await runCli ( [ "backup" , "create" , "--verify" ] ) ;
7375
74- expect ( backupCreateCommand ) . toHaveBeenCalledWith (
75- runtime ,
76- expect . objectContaining ( {
77- verify : true ,
78- } ) ,
79- ) ;
76+ const options = expectForwardedOptions ( backupCreateCommand ) ;
77+ expect ( options . verify ) . toBe ( true ) ;
8078 } ) ;
8179
8280 it ( "forwards --only-config to backup create" , async ( ) => {
8381 await runCli ( [ "backup" , "create" , "--only-config" ] ) ;
8482
85- expect ( backupCreateCommand ) . toHaveBeenCalledWith (
86- runtime ,
87- expect . objectContaining ( {
88- onlyConfig : true ,
89- } ) ,
90- ) ;
83+ const options = expectForwardedOptions ( backupCreateCommand ) ;
84+ expect ( options . onlyConfig ) . toBe ( true ) ;
9185 } ) ;
9286
9387 it ( "runs backup verify with forwarded options" , async ( ) => {
9488 await runCli ( [ "backup" , "verify" , "/tmp/openclaw-backup.tar.gz" , "--json" ] ) ;
9589
96- expect ( backupVerifyCommand ) . toHaveBeenCalledWith (
97- runtime ,
98- expect . objectContaining ( {
99- archive : "/tmp/openclaw-backup.tar.gz" ,
100- json : true ,
101- } ) ,
102- ) ;
90+ const options = expectForwardedOptions ( backupVerifyCommand ) ;
91+ expect ( options . archive ) . toBe ( "/tmp/openclaw-backup.tar.gz" ) ;
92+ expect ( options . json ) . toBe ( true ) ;
10393 } ) ;
10494} ) ;
0 commit comments