@@ -2,6 +2,15 @@ import { describe, it, expect, vi } from "vitest";
22import { Conflict , MergeContext , mergeObject , BuiltInStrategies , statusToString } from "./merger" ;
33import { DROP } from "./utils" ;
44
5+ // Mock logger
6+ const mockLogger = {
7+ debug : vi . fn ( ) ,
8+ info : vi . fn ( ) ,
9+ warn : vi . fn ( ) ,
10+ error : vi . fn ( ) ,
11+ flush : vi . fn ( ) ,
12+ } ;
13+
514// Mock resolveStrategies so we control strategy order
615vi . mock ( "./strategy-resolver" , ( ) => ( {
716 resolveStrategies : vi . fn ( ( ) => [ "ours" , "theirs" , "merge" ] ) ,
@@ -33,7 +42,15 @@ describe("statusToString", () => {
3342
3443describe ( "BuiltInStrategies" , ( ) => {
3544 const ctx = makeCtx ( ) ;
36- const args = { ours : 1 , theirs : 2 , base : 0 , path : "x" , ctx, conflicts : [ ] as Conflict [ ] } ;
45+ const args = {
46+ ours : 1 ,
47+ theirs : 2 ,
48+ base : 0 ,
49+ path : "x" ,
50+ ctx,
51+ conflicts : [ ] as Conflict [ ] ,
52+ logger : mockLogger ,
53+ } ;
3754
3855 it ( "ours returns ours" , ( ) => {
3956 const r = BuiltInStrategies . ours ( args ) ;
@@ -96,6 +113,7 @@ describe("BuiltInStrategies", () => {
96113 theirs : { a : 2 } ,
97114 base : { a : 0 } ,
98115 path : "obj" ,
116+ logger : mockLogger ,
99117 } ;
100118 const r = await BuiltInStrategies . merge ( objArgs ) ;
101119 expect ( r . status ) . toBe ( StrategyStatus_OK ) ;
@@ -113,7 +131,15 @@ describe("mergeObject", () => {
113131 it ( "returns ours if equal" , async ( ) => {
114132 const ctx = makeCtx ( ) ;
115133 const conflicts : Conflict [ ] = [ ] ;
116- const v = await mergeObject ( { ours : 1 , theirs : 1 , base : 0 , path : "x" , ctx, conflicts } ) ;
134+ const v = await mergeObject ( {
135+ ours : 1 ,
136+ theirs : 1 ,
137+ base : 0 ,
138+ path : "x" ,
139+ ctx,
140+ conflicts,
141+ logger : mockLogger ,
142+ } ) ;
117143 expect ( v ) . toBe ( 1 ) ;
118144 expect ( conflicts ) . toHaveLength ( 0 ) ;
119145 } ) ;
@@ -122,15 +148,29 @@ describe("mergeObject", () => {
122148 ( resolveStrategies as any ) . mockReturnValueOnce ( [ "theirs" ] ) ;
123149 const ctx = makeCtx ( ) ;
124150 const conflicts : Conflict [ ] = [ ] ;
125- const v = await mergeObject ( { ours : 1 , theirs : 2 , path : "p" , ctx, conflicts } ) ;
151+ const v = await mergeObject ( {
152+ ours : 1 ,
153+ theirs : 2 ,
154+ path : "p" ,
155+ ctx,
156+ conflicts,
157+ logger : mockLogger ,
158+ } ) ;
126159 expect ( v ) . toBe ( 2 ) ;
127160 } ) ;
128161
129162 it ( "records SKIP as conflict" , async ( ) => {
130163 ( resolveStrategies as any ) . mockReturnValueOnce ( [ "skip" ] ) ;
131164 const ctx = makeCtx ( ) ;
132165 const conflicts : Conflict [ ] = [ ] ;
133- const v = await mergeObject ( { ours : "a" , theirs : "b" , path : "p" , ctx, conflicts } ) ;
166+ const v = await mergeObject ( {
167+ ours : "a" ,
168+ theirs : "b" ,
169+ path : "p" ,
170+ ctx,
171+ conflicts,
172+ logger : mockLogger ,
173+ } ) ;
134174 expect ( v ) . toBeUndefined ( ) ;
135175 expect ( conflicts [ 0 ] . reason ) . toMatch ( / S k i p / ) ;
136176 } ) ;
@@ -139,7 +179,15 @@ describe("mergeObject", () => {
139179 ( resolveStrategies as any ) . mockReturnValueOnce ( [ "non-empty" ] ) ;
140180 const ctx = makeCtx ( ) ;
141181 const conflicts : Conflict [ ] = [ ] ;
142- const v = await mergeObject ( { ours : "" , theirs : "" , base : "" , path : "p" , ctx, conflicts } ) ;
182+ const v = await mergeObject ( {
183+ ours : "" ,
184+ theirs : "" ,
185+ base : "" ,
186+ path : "p" ,
187+ ctx,
188+ conflicts,
189+ logger : mockLogger ,
190+ } ) ;
143191 expect ( v ) . toBeUndefined ( ) ;
144192 expect ( conflicts [ 0 ] ) . toMatchObject ( {
145193 path : "p" ,
0 commit comments