@@ -1365,6 +1365,78 @@ describe('cli', function () {
13651365 verifyPackageVersion ( { writeFileSyncSpy, expectedVersion : '1.1.0' } ) ;
13661366 } ) ;
13671367
1368+ it ( 'bumps version in Dart `pubspec.yaml` file' , async function ( ) {
1369+ const expected = fs . readFileSync (
1370+ './test/mocks/pubspec-6.4.0.yaml' ,
1371+ 'utf-8' ,
1372+ ) ;
1373+
1374+ const filename = 'pubspec.yaml' ;
1375+ mock ( {
1376+ bump : 'minor' ,
1377+ realTestFiles : [
1378+ {
1379+ filename,
1380+ path : './test/mocks/pubspec-6.3.1.yaml' ,
1381+ } ,
1382+ ] ,
1383+ } ) ;
1384+
1385+ await exec ( {
1386+ packageFiles : [ { filename, type : 'yaml' } ] ,
1387+ bumpFiles : [ { filename, type : 'yaml' } ] ,
1388+ } ) ;
1389+
1390+ // filePath is the first arg passed to writeFileSync
1391+ const packageJsonWriteFileSynchCall = findWriteFileCallForPath ( {
1392+ writeFileSyncSpy,
1393+ filename,
1394+ } ) ;
1395+
1396+ if ( ! packageJsonWriteFileSynchCall ) {
1397+ throw new Error ( `writeFileSynch not invoked with path ${ filename } ` ) ;
1398+ }
1399+
1400+ const calledWithContentStr = packageJsonWriteFileSynchCall [ 1 ] ;
1401+ expect ( calledWithContentStr ) . toEqual ( expected ) ;
1402+ } ) ;
1403+
1404+ it ( 'bumps version in Dart `pubspec.yaml` file with CRLF line endings' , async function ( ) {
1405+ const expected = fs . readFileSync (
1406+ './test/mocks/pubspec-6.4.0-crlf.yaml' ,
1407+ 'utf-8' ,
1408+ ) ;
1409+
1410+ const filename = 'pubspec.yaml' ;
1411+ mock ( {
1412+ bump : 'minor' ,
1413+ realTestFiles : [
1414+ {
1415+ filename,
1416+ path : './test/mocks/pubspec-6.3.1-crlf.yaml' ,
1417+ } ,
1418+ ] ,
1419+ } ) ;
1420+
1421+ await exec ( {
1422+ packageFiles : [ { filename, type : 'yaml' } ] ,
1423+ bumpFiles : [ { filename, type : 'yaml' } ] ,
1424+ } ) ;
1425+
1426+ // filePath is the first arg passed to writeFileSync
1427+ const packageJsonWriteFileSynchCall = findWriteFileCallForPath ( {
1428+ writeFileSyncSpy,
1429+ filename,
1430+ } ) ;
1431+
1432+ if ( ! packageJsonWriteFileSynchCall ) {
1433+ throw new Error ( `writeFileSynch not invoked with path ${ filename } ` ) ;
1434+ }
1435+
1436+ const calledWithContentStr = packageJsonWriteFileSynchCall [ 1 ] ;
1437+ expect ( calledWithContentStr ) . toEqual ( expected ) ;
1438+ } ) ;
1439+
13681440 describe ( 'skip' , function ( ) {
13691441 it ( 'allows bump and changelog generation to be skipped' , async function ( ) {
13701442 const changelogContent = 'legacy header format<a name="1.0.0">\n' ;
0 commit comments