@@ -10,126 +10,127 @@ import { namedFilesDesc, oneChange } from "../../generate/message";
1010
1111describe ( "Generate commit message for a single changed file" , function ( ) {
1212 // Notes:
13- // - The command `git status --short` expects XY format but this is for `git diff-index` which
14- // is only X. Also there is just spaces between - no '->' symbol.
15- // - Impossible cases are not covered here, like renaming a file and the name and path are
16- // unchanged, or including two file names for an add line. But validation on at least file
17- // name is done.
13+ // - The command `git status --short` expects XY format but this is for `git
14+ // diff-index` which is only X. Also there is just spaces between - no
15+ // '->' symbol.
16+ // - Impossible cases are not covered here, like renaming a file and the
17+ // name and path are unchanged, or including two file names for an add
18+ // line. But validation on at least file name is done.
1819 describe ( "#oneChange" , function ( ) {
1920 it ( "returns the appropriate commit message for a new file" , function ( ) {
20- assert . strictEqual ( oneChange ( "A foo .txt" ) , "create foo.txt" ) ;
21+ assert . strictEqual ( oneChange ( "A\tfoo .txt" ) , "create foo.txt" ) ;
2122 // Maybe create foo.txt in bar, if the dir is not too long?
22- assert . strictEqual ( oneChange ( "A bar /foo.txt" ) , "create foo.txt" ) ;
23+ assert . strictEqual ( oneChange ( "A\tbar /foo.txt" ) , "create foo.txt" ) ;
2324 } ) ;
2425
2526 it ( "throws an error if no filepath can be no generated" , function ( ) {
2627 assert . throws ( ( ) => oneChange ( "A " ) ) ;
2728 } ) ;
2829
2930 it ( "returns the appropriate commit message for a modified file" , function ( ) {
30- assert . strictEqual ( oneChange ( "M foo .txt" ) , "update foo.txt" ) ;
31- assert . strictEqual ( oneChange ( "M bar /foo.txt" ) , "update foo.txt" ) ;
31+ assert . strictEqual ( oneChange ( "M\tfoo .txt" ) , "update foo.txt" ) ;
32+ assert . strictEqual ( oneChange ( "M\tbar /foo.txt" ) , "update foo.txt" ) ;
3233 } ) ;
3334
3435 it ( "returns the appropriate commit message for a deleted file" , function ( ) {
35- assert . strictEqual ( oneChange ( "D foo .txt" ) , "delete foo.txt" ) ;
36- assert . strictEqual ( oneChange ( "D bar /foo.txt" ) , "delete foo.txt" ) ;
36+ assert . strictEqual ( oneChange ( "D\tfoo .txt" ) , "delete foo.txt" ) ;
37+ assert . strictEqual ( oneChange ( "D\tbar /foo.txt" ) , "delete foo.txt" ) ;
3738 } ) ;
3839
3940 it ( "describes a file renamed in the same directory" , function ( ) {
4041 assert . strictEqual (
41- oneChange ( "R foo .txt bar .txt" ) ,
42+ oneChange ( "R\tfoo .txt\tbar .txt" ) ,
4243 "rename foo.txt to bar.txt"
4344 ) ;
4445
4546 assert . strictEqual (
46- oneChange ( "R fizz /foo.txt fizz /bar.txt" ) ,
47+ oneChange ( "R\tfizz /foo.txt\tfizz /bar.txt" ) ,
4748 "rename foo.txt to bar.txt"
4849 ) ;
4950 } ) ;
5051
5152 it ( "ignores percentage change in a renamed file" , function ( ) {
52- // We don't care about getting the percentage out in this project. So just make sure it does
53- // get ignored.
53+ // We don't care about getting the percentage out in this project. So just
54+ // make sure it does get ignored.
5455 assert . strictEqual (
55- oneChange ( "R97 foo .txt bar .txt" ) ,
56+ oneChange ( "R97\tfoo .txt\tbar .txt" ) ,
5657 "rename foo.txt to bar.txt"
5758 ) ;
5859 } ) ;
5960
6061 it ( "describes a file moved out of the repo root" , function ( ) {
6162 assert . strictEqual (
62- oneChange ( "R foo .txt fizz /foo.txt" ) ,
63+ oneChange ( "R\tfoo .txt\tfizz /foo.txt" ) ,
6364 "move foo.txt to fizz"
6465 ) ;
6566
6667 assert . strictEqual (
67- oneChange ( "R foo .txt fizz /buzz/foo.txt" ) ,
68+ oneChange ( "R\tfoo .txt\tfizz /buzz/foo.txt" ) ,
6869 "move foo.txt to fizz/buzz"
6970 ) ;
7071 } ) ;
7172
7273 it ( "describes a file moved out of a subdirectory" , function ( ) {
7374 assert . strictEqual (
74- oneChange ( "R fizz /buzz/foo.txt foo .txt" ) ,
75+ oneChange ( "R\tfizz /buzz/foo.txt\tfoo .txt" ) ,
7576 "move foo.txt to repo root"
7677 ) ;
7778
7879 assert . strictEqual (
79- oneChange ( "R fizz /buzz/foo.txt fizz /foo.txt" ) ,
80+ oneChange ( "R\tfizz /buzz/foo.txt\tfizz /foo.txt" ) ,
8081 "move foo.txt to fizz"
8182 ) ;
8283
8384 assert . strictEqual (
84- oneChange ( "R fizz /buzz/foo.txt fizz /buzz/foo.txt" ) ,
85+ oneChange ( "R\tfizz /buzz/foo.txt\tfizz /buzz/foo.txt" ) ,
8586 "move foo.txt to fizz/buzz"
8687 ) ;
8788 } ) ;
8889
8990 it ( "describes a file that was both moved and renamed" , function ( ) {
9091 assert . strictEqual (
91- oneChange ( "R foo .txt fizz /fuzz.txt" ) ,
92+ oneChange ( "R\tfoo .txt\tfizz /fuzz.txt" ) ,
9293 "move and rename foo.txt to fizz/fuzz.txt"
9394 ) ;
9495
9596 assert . strictEqual (
96- oneChange ( "R bar /foo.txt fuzz .txt" ) ,
97+ oneChange ( "R\tbar /foo.txt\tfuzz .txt" ) ,
9798 "move and rename foo.txt to fuzz.txt at repo root"
9899 ) ;
99100
100101 assert . strictEqual (
101- oneChange ( "R bar /foo.txt fizz /fuzz.txt" ) ,
102+ oneChange ( "R\tbar /foo.txt\tfizz /fuzz.txt" ) ,
102103 "move and rename foo.txt to fizz/fuzz.txt"
103104 ) ;
104105 } ) ;
105106
106107 it ( "ignores percentage changed value for a file that was both moved and renamed" , function ( ) {
107108 assert . strictEqual (
108- oneChange ( "R97 foo .txt fizz /fuzz.txt" ) ,
109+ oneChange ( "R97\tfoo .txt\tfizz /fuzz.txt" ) ,
109110 "move and rename foo.txt to fizz/fuzz.txt"
110111 ) ;
111112 } ) ;
112113
113114 it ( "uses the full path to describe index files" , function ( ) {
114- assert . strictEqual ( oneChange ( "A README .md" ) , "create README.md" ) ;
115- assert . strictEqual ( oneChange ( "M README .md" ) , "update README.md" ) ;
116- assert . strictEqual ( oneChange ( "D README .md" ) , "delete README.md" ) ;
115+ assert . strictEqual ( oneChange ( "A\tREADME .md" ) , "create README.md" ) ;
116+ assert . strictEqual ( oneChange ( "M\tREADME .md" ) , "update README.md" ) ;
117+ assert . strictEqual ( oneChange ( "D\tREADME .md" ) , "delete README.md" ) ;
117118
118119 assert . strictEqual (
119- oneChange ( "A foo /README.md" ) ,
120+ oneChange ( "A\tfoo /README.md" ) ,
120121 "create foo/README.md"
121122 ) ;
122123 assert . strictEqual (
123- oneChange ( "M bar /baz/README.md" ) ,
124+ oneChange ( "M\tbar /baz/README.md" ) ,
124125 "update bar/baz/README.md"
125126 ) ;
126127 assert . strictEqual (
127- oneChange ( "D bar /baz/buzz/README.md" ) ,
128+ oneChange ( "D\tbar /baz/buzz/README.md" ) ,
128129 "delete bar/baz/buzz/README.md"
129130 ) ;
130131
131- assert . strictEqual ( oneChange ( "A foo /index.md" ) , "create foo/index.md" ) ;
132- assert . strictEqual ( oneChange ( "A foo /index.js" ) , "create foo/index.js" ) ;
132+ assert . strictEqual ( oneChange ( "A\tfoo /index.md" ) , "create foo/index.md" ) ;
133+ assert . strictEqual ( oneChange ( "A\tfoo /index.js" ) , "create foo/index.js" ) ;
133134 } ) ;
134135 } ) ;
135136} ) ;
0 commit comments