Skip to content

Commit

Permalink
test: add test for hiding unstaged changes in renamed file
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnywalker committed May 28, 2020
1 parent ea80a3d commit 390d168
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/gitWorkflow.spec.js
Expand Up @@ -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 })

Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit 390d168

Please sign in to comment.