Skip to content

Commit

Permalink
tests: Add more tests for renamed and untracked files
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Okonetchnikov committed Oct 21, 2018
1 parent 815a2ab commit da2adf9
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion test/gitStash.spec.js
Expand Up @@ -122,7 +122,7 @@ M test.js"
`)
})

it('should not restore deleted files', async () => {
it('should not re-create deleted files as untracked files', async () => {
// Delete test.js
await gitflow.execGit(['checkout', 'test.js'], gitOpts)
await gitflow.execGit(['rm', 'test.js'], gitOpts)
Expand All @@ -143,6 +143,50 @@ D test.js"
`)
})

it('should handle renamed files', async () => {
// Delete test.js
await gitflow.execGit(['checkout', 'test.js'], gitOpts)
await gitflow.execGit(['mv', 'test.js', 'test-renamed.js'], gitOpts)
expect(await gitStatus()).toMatchInlineSnapshot(`
"R test.js -> test-renamed.js
M test.css"
`)

// Stashing files
await gitflow.gitStashSave(gitOpts)
expect(await gitStatus()).toMatchInlineSnapshot(`"R test.js -> test-renamed.js"`)

// Restoring state
await gitflow.gitStashPop(gitOpts)
expect(await gitStatus()).toMatchInlineSnapshot(`
"R test.js -> test-renamed.js
M test.css"
`)
})

it('should handle rename and reset (both deleted and untracked) files', async () => {
// Delete test.js
await gitflow.execGit(['checkout', 'test.js'], gitOpts)
await gitflow.execGit(['mv', 'test.js', 'test-renamed.js'], gitOpts)
await gitflow.execGit(['reset', '.'], gitOpts)
expect(await gitStatus()).toMatchInlineSnapshot(`
" M test.css
D test.js
?? test-renamed.js"
`)

// Stashing files
await gitflow.gitStashSave(gitOpts)
expect(await gitStatus()).toMatchInlineSnapshot(`"?? test-renamed.js"`)

// Restoring state
await gitflow.gitStashPop(gitOpts)
expect(await gitStatus()).toMatchInlineSnapshot(`
" M test.css
?? test-renamed.js"
`)

This comment has been minimized.

Copy link
@trusktr

trusktr Nov 7, 2018

Where'd the deleted file go? Is gitStashSave doing same as what git stash save does? If so, I expect the deleted file to be there when popping the stash.

This comment has been minimized.

Copy link
@okonet

okonet Nov 7, 2018

Collaborator

Feel free to dig deeper and propose a PR

})

it('should drop hooks fixes when aborted', async () => {
expect(await gitStatus()).toMatchInlineSnapshot(`
" M test.css
Expand Down

0 comments on commit da2adf9

Please sign in to comment.