diff --git a/test/gitWorkflow.spec.js b/test/gitWorkflow.spec.js index 7ab711871..8752921eb 100644 --- a/test/gitWorkflow.spec.js +++ b/test/gitWorkflow.spec.js @@ -19,6 +19,8 @@ let tmpDir, cwd const appendFile = async (filename, content, dir = cwd) => fs.appendFile(path.resolve(dir, filename), content) +const readFile = async (filename, dir = cwd) => fs.readFile(path.resolve(dir, filename)) + /** Wrap execGit to always pass `gitOps` */ const execGit = async (args) => execGitBase(args, { cwd }) @@ -162,6 +164,20 @@ describe('gitWorkflow', () => { } `) }) + it('should checkout renamed file when hiding changes', async () => { + const gitWorkflow = new GitWorkflow({ + gitDir: cwd, + gitConfigDir: path.resolve(cwd, './.git'), + }) + const origContent = await readFile('README.md') + await execGit(['mv', 'README.md', 'TEST.md']) + await appendFile('TEST.md', 'added content') + + gitWorkflow.partiallyStagedFiles = await gitWorkflow.getPartiallyStagedFiles() + const ctx = getInitialState() + await gitWorkflow.hideUnstagedChanges(ctx) + expect(await readFile('TEST.md')).toStrictEqual(origContent) + }) }) describe('restoreMergeStatus', () => {