@@ -7,7 +7,6 @@ import * as assert from "assert";
77import { MsgPieces } from "../generate/parseExisting.d" ;
88import { CONVENTIONAL_TYPE } from "../lib/constants" ;
99import {
10- generateMsg ,
1110 _collapse ,
1211 _combineOldAndNew ,
1312 _formatMsg ,
@@ -19,6 +18,7 @@ import {
1918 _msgNamed ,
2019 _newMsg ,
2120 _prefixFromChange ,
21+ generateMsg ,
2222} from "../prepareCommitMsg" ;
2323import { ConvCommitMsg } from "../prepareCommitMsg.d" ;
2424
@@ -712,6 +712,10 @@ describe("Prepare commit message", function () {
712712 it ( "handles a single created file" , function ( ) {
713713 assert . strictEqual ( _newMsg ( [ "A\tbaz.txt" ] ) , "feat: create baz.txt" ) ;
714714 } ) ;
715+
716+ it ( "handles a single created file with special characters" , function ( ) {
717+ assert . strictEqual ( _newMsg ( [ "A\tspëcial châracters.md" ] ) , "feat: create 'spëcial châracters.md'" ) ;
718+ } ) ;
715719 } ) ;
716720
717721 describe ( "multiple changes" , function ( ) {
@@ -1530,5 +1534,55 @@ describe("Prepare commit message", function () {
15301534 "update baz.txt and bar.js" ,
15311535 ) ;
15321536 } ) ;
1537+
1538+ it ( "handles a single file change with a set old message" , function ( ) {
1539+ const singleFileChange = [ "M\tbaz.txt" ] ;
1540+ const oldMsg = "my old message" ;
1541+
1542+ assert . strictEqual (
1543+ generateMsg ( singleFileChange , oldMsg ) ,
1544+ "update baz.txt my old message" ,
1545+ ) ;
1546+ } ) ;
1547+
1548+ it ( "handles a single file change with an empty old message" , function ( ) {
1549+ const singleFileChange = [ "M\tbaz.txt" ] ;
1550+ const oldMsg = "" ;
1551+
1552+ assert . strictEqual (
1553+ generateMsg ( singleFileChange , oldMsg ) ,
1554+ "update baz.txt" ,
1555+ ) ;
1556+ } ) ;
1557+
1558+ it ( "handles multiple file changes with a set old message" , function ( ) {
1559+ const multipleFileChanges = [ "M\tbaz.txt" , "M\tbar.js" , "M\tfoo.txt" ] ;
1560+ const oldMsg = "my old message" ;
1561+
1562+ assert . strictEqual (
1563+ generateMsg ( multipleFileChanges , oldMsg ) ,
1564+ "update baz.txt, bar.js and foo.txt my old message" ,
1565+ ) ;
1566+ } ) ;
1567+
1568+ it ( "handles multiple file changes with an empty old message" , function ( ) {
1569+ const multipleFileChanges = [ "M\tbaz.txt" , "M\tbar.js" , "M\tfoo.txt" ] ;
1570+ const oldMsg = "" ;
1571+
1572+ assert . strictEqual (
1573+ generateMsg ( multipleFileChanges , oldMsg ) ,
1574+ "update baz.txt, bar.js and foo.txt" ,
1575+ ) ;
1576+ } ) ;
1577+
1578+ it ( "handles a single file change with special characters" , function ( ) {
1579+ const singleFileChange = [ "M\tspëcial châracters.md" ] ;
1580+ const oldMsg = "" ;
1581+
1582+ assert . strictEqual (
1583+ generateMsg ( singleFileChange , oldMsg ) ,
1584+ "update 'spëcial châracters.md'" ,
1585+ ) ;
1586+ } ) ;
15331587 } ) ;
15341588} ) ;
0 commit comments