From da2adf9a066749bcea74910a86d9de9791f602e5 Mon Sep 17 00:00:00 2001 From: Andrey Okonetchnikov Date: Sun, 21 Oct 2018 23:44:31 +0200 Subject: [PATCH] tests: Add more tests for renamed and untracked files --- test/gitStash.spec.js | 46 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/test/gitStash.spec.js b/test/gitStash.spec.js index da7bce147..bbf9cbd77 100644 --- a/test/gitStash.spec.js +++ b/test/gitStash.spec.js @@ -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) @@ -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" +`) + }) + it('should drop hooks fixes when aborted', async () => { expect(await gitStatus()).toMatchInlineSnapshot(` " M test.css