@@ -9,98 +9,96 @@ import { parseDiffIndex, parseStatus } from "../../git/parseOutput";
99import { FileChange } from "../../git/parseOutput.d" ;
1010
1111describe ( "Split `git diff-index` output into components" , function ( ) {
12- // The 1st to 2nd column gap looks like 4 chars and then 2nd to 3rd looks like
13- // 6 chars.
14- // R100 tslint.json src/tslint.json
15- // R100 vsc-extension-quickstart.md src/vsc-extension-quickstart.md
1612 describe ( "#parseDiffIndex" , function ( ) {
17- it ( "should return the appropriate commit message for a new file" , function ( ) {
18- const expected : FileChange = {
19- x : "A" ,
20- y : " " ,
21- from : "foo.txt" ,
22- to : "" ,
23- } ;
13+ describe ( "states with a single path" , function ( ) {
14+ it ( "should return the appropriate commit message for a new file" , function ( ) {
15+ const expected : FileChange = {
16+ x : "A" ,
17+ y : " " ,
18+ from : "foo.txt" ,
19+ to : "" ,
20+ } ;
2421
25- assert . deepStrictEqual ( parseDiffIndex ( "A foo.txt" ) , expected ) ;
26- assert . deepStrictEqual ( parseDiffIndex ( "A foo.txt" ) , expected ) ;
27- assert . deepStrictEqual ( parseDiffIndex ( "A\tfoo.txt" ) , expected ) ;
28- } ) ;
22+ assert . deepStrictEqual ( parseDiffIndex ( "A\tfoo.txt" ) , expected ) ;
23+ } ) ;
2924
30- it ( "should return the appropriate commit message for a modified file" , function ( ) {
31- const expected : FileChange = {
32- x : "M" ,
33- y : " " ,
34- from : "foo.txt" ,
35- to : "" ,
36- } ;
25+ it ( "should return the appropriate commit message for a modified file" , function ( ) {
26+ const expected : FileChange = {
27+ x : "M" ,
28+ y : " " ,
29+ from : "foo.txt" ,
30+ to : "" ,
31+ } ;
3732
38- assert . deepStrictEqual ( parseDiffIndex ( "M foo .txt" ) , expected ) ;
39- } ) ;
33+ assert . deepStrictEqual ( parseDiffIndex ( "M\tfoo .txt" ) , expected ) ;
34+ } ) ;
4035
41- it ( "should return the appropriate commit message for a deleted file" , function ( ) {
42- const expected : FileChange = {
43- x : "D" ,
44- y : " " ,
45- from : "foo.txt" ,
46- to : "" ,
47- } ;
36+ it ( "should return the appropriate commit message for a deleted file" , function ( ) {
37+ const expected : FileChange = {
38+ x : "D" ,
39+ y : " " ,
40+ from : "foo.txt" ,
41+ to : "" ,
42+ } ;
4843
49- assert . deepStrictEqual ( parseDiffIndex ( "D foo.txt" ) , expected ) ;
44+ assert . deepStrictEqual ( parseDiffIndex ( "D\tfoo.txt" ) , expected ) ;
45+ } ) ;
5046 } ) ;
5147
52- it ( "should return the appropriate commit message for a renamed unchanged file" , function ( ) {
53- const expected : FileChange = {
54- x : "R" ,
55- y : " " ,
56- from : "bar.txt" ,
57- to : "foo.txt" ,
58- } ;
59-
60- assert . deepStrictEqual (
61- parseDiffIndex ( "R100 bar.txt foo.txt" ) ,
62- expected
63- ) ;
64-
65- it ( "should return the appropriate commit message for a moved file" , function ( ) {
48+ describe ( "states with two paths" , function ( ) {
49+ it ( "should return the appropriate commit message for a renamed unchanged file" , function ( ) {
6650 const expected : FileChange = {
6751 x : "R" ,
6852 y : " " ,
6953 from : "bar.txt" ,
70- to : "fizz/ foo.txt" ,
54+ to : "foo.txt" ,
7155 } ;
7256
7357 assert . deepStrictEqual (
74- parseDiffIndex ( "R100 bar .txt fizz/foo .txt" ) ,
58+ parseDiffIndex ( "R100\tbar .txt\tfoo .txt" ) ,
7559 expected
7660 ) ;
77- } ) ;
78- } ) ;
7961
80- it ( "returns a correct commit message for a renamed modified file" , function ( ) {
81- const expected : FileChange = {
82- x : "R" ,
83- y : " " ,
84- from : "bar.txt" ,
85- to : "foo.txt" ,
86- } ;
87- assert . deepStrictEqual (
88- parseDiffIndex ( "R096 bar.txt foo.txt" ) ,
89- expected
90- ) ;
62+ it ( "should return the appropriate commit message for a moved file" , function ( ) {
63+ const expected : FileChange = {
64+ x : "R" ,
65+ y : " " ,
66+ from : "bar.txt" ,
67+ to : "fizz/foo.txt" ,
68+ } ;
69+
70+ assert . deepStrictEqual (
71+ parseDiffIndex ( "R100\tbar.txt\tfizz/foo.txt" ) ,
72+ expected
73+ ) ;
74+ } ) ;
75+ } ) ;
9176
92- it ( "should return the appropriate commit message for a moved file" , function ( ) {
77+ it ( "returns a correct commit message for a renamed modified file" , function ( ) {
9378 const expected : FileChange = {
9479 x : "R" ,
9580 y : " " ,
96- to : "bar.txt" ,
97- from : "fizz/ foo.txt" ,
81+ from : "bar.txt" ,
82+ to : "foo.txt" ,
9883 } ;
99-
10084 assert . deepStrictEqual (
101- parseDiffIndex ( "R096 bar .txt fizz/foo .txt" ) ,
85+ parseDiffIndex ( "R096\tbar .txt\tfoo .txt" ) ,
10286 expected
10387 ) ;
88+
89+ it ( "should return the appropriate commit message for a moved file" , function ( ) {
90+ const expected : FileChange = {
91+ x : "R" ,
92+ y : " " ,
93+ to : "bar.txt" ,
94+ from : "fizz/foo.txt" ,
95+ } ;
96+
97+ assert . deepStrictEqual (
98+ parseDiffIndex ( "R096\tbar.txt\tfizz/foo.txt" ) ,
99+ expected
100+ ) ;
101+ } ) ;
104102 } ) ;
105103 } ) ;
106104
@@ -122,7 +120,7 @@ describe("Split `git status` output into components", function () {
122120 to : "" ,
123121 } ;
124122
125- assert . deepStrictEqual ( parseStatus ( "A foo .txt" ) , expected ) ;
123+ assert . deepStrictEqual ( parseStatus ( "A \tfoo .txt" ) , expected ) ;
126124 } ) ;
127125
128126 it ( "should return the appropriate commit message for a modified file" , function ( ) {
@@ -133,7 +131,7 @@ describe("Split `git status` output into components", function () {
133131 to : "" ,
134132 } ;
135133
136- assert . deepStrictEqual ( parseStatus ( " M foo .txt" ) , expected ) ;
134+ assert . deepStrictEqual ( parseStatus ( " M\tfoo .txt" ) , expected ) ;
137135 } ) ;
138136
139137 it ( "should return the appropriate commit message for a deleted file" , function ( ) {
0 commit comments