import{a as w}from"./chunk-SIWBT4LK.mjs";import{g as u,h as l,j as b,k as d}from"./chunk-QPV2G662.mjs";import{a as c,b as s,c as m,d as p,g as a}from"./chunk-IFUYCFBO.mjs";import"./chunk-76CZ6Z7T.mjs";import e from"fs/promises";import t from"path";var f=w,o=t.join(process.cwd(),"tmp-test");m(async()=>{await e.rm(o,{recursive:!0,force:!0}),await e.mkdir(o,{recursive:!0}),await e.writeFile(t.join(o,"clean.txt"),"hello"),await e.writeFile(t.join(o,"conflict.txt"),`line1
<<<<<<< ours
conflict
=======
theirs
>>>>>>>`),await e.mkdir(t.join(o,"src")),await e.writeFile(t.join(o,"src","index.ts"),"console.log('ok')"),await e.mkdir(t.join(o,"node_modules")),await e.writeFile(t.join(o,"node_modules","ignore.js"),"ignored")});p(async()=>{await e.rm(o,{recursive:!0,force:!0}),await e.rm(".merge-backups",{recursive:!0,force:!0})});c("hasConflict",()=>{s("detects conflict markers",()=>{a(u(`<<<<<<<
=======
>>>>>>>`)).toBe(!0)}),s("returns false for clean content",()=>{a(u("no conflicts here")).toBe(!1)})});c("listMatchingFiles",()=>{s("finds only conflicted files by default",async()=>{let i=(await l({root:o,include:["**/*.txt"],exclude:["node_modules/**"],matcher:f})).map(r=>t.basename(r.filePath));a(i).toContain("conflict.txt"),a(i).not.toContain("clean.txt")}),s("includes non-conflicted if option enabled",async()=>{let i=(await l({root:o,include:["**/*.txt"],exclude:[],matcher:f,includeNonConflicted:!0})).map(r=>t.basename(r.filePath));a(i).toEqual(a.arrayContaining(["clean.txt","conflict.txt"]))}),s("only files - no dirs",async()=>{let i=(await l({root:o,include:["*.txt"],exclude:[],matcher:f})).map(r=>t.basename(r.filePath));a(i).toEqual(a.arrayContaining(["conflict.txt"]))})});c("backupFile",()=>{s("creates backup copy under .merge-backups",async()=>{let n=t.join(o,"clean.txt"),i=await b(n),r=await e.readFile(i,"utf8");a(r).toBe("hello"),a(i).toMatch(/\.merge-backups/)})});c("restoreBackups",()=>{s("restores files from backup directory",async()=>{process.chdir(o);let n="test-backup",i="restore-test.txt";await e.mkdir(n,{recursive:!0}),await e.writeFile(t.join(n,"restore-test.txt"),"restored"),await d(n);let r=await e.readFile(i,"utf8");a(r).toBe("restored")}),s("restores nested directory structure",async()=>{let n="nested-backup",i=t.join(n,"sub","deep");await e.mkdir(i,{recursive:!0}),await e.writeFile(t.join(i,"nested.txt"),"deep file"),await d(n);let r=await e.readFile(t.join("sub","deep","nested.txt"),"utf8");a(r).toBe("deep file"),process.chdir("..")})});
