@@ -605,7 +605,11 @@ describe('git_changelog_generate.js', function() {
605
605
} ) ;
606
606
607
607
describe ( '.organizeCommits()' , function ( ) {
608
-
608
+ function findItem ( key , value ) {
609
+ return function ( item ) {
610
+ return item [ key ] === value
611
+ }
612
+ }
609
613
describe ( 'without breaking commits' , function ( ) {
610
614
611
615
before ( function ( ) {
@@ -649,15 +653,10 @@ describe('git_changelog_generate.js', function() {
649
653
this . sections = changelog . organizeCommits ( this . commits , this . sections ) ;
650
654
} ) ;
651
655
652
- it ( 'should return 8 sections' , function ( ) {
653
- expect ( this . sections . length ) . to . equal ( 8 ) ;
656
+ it ( 'should return 3 sections' , function ( ) {
657
+ expect ( this . sections . length ) . to . equal ( 3 ) ;
654
658
} ) ;
655
659
656
- function findItem ( key , value ) {
657
- return function ( item ) {
658
- return item [ key ] === value
659
- }
660
- }
661
660
it ( 'should fix section to have 1 commit' , function ( ) {
662
661
expect ( this . sections . find ( findItem ( 'type' , 'fix' ) ) . components . find ( findItem ( 'name' , '$scope' ) ) . commits . length ) . to . equal ( 1 ) ;
663
662
} ) ;
@@ -696,16 +695,40 @@ describe('git_changelog_generate.js', function() {
696
695
697
696
before ( function ( ) {
698
697
changelog . setDefaults ( ) ;
699
- this . sections = {
700
- fix : { } ,
701
- feat : { } ,
702
- BREAKING : { } ,
703
- style : { } ,
704
- refactor : { } ,
705
- test : { } ,
706
- chore : { } ,
707
- docs : { }
708
- } ;
698
+ this . sections = [
699
+ {
700
+ title : 'Bug Fixes' ,
701
+ grep : '^fix'
702
+ } ,
703
+ {
704
+ title : 'Features' ,
705
+ grep : '^feat'
706
+ } ,
707
+ {
708
+ title : 'Documentation' ,
709
+ grep : '^docs'
710
+ } ,
711
+ {
712
+ title : 'Breaking changes' ,
713
+ grep : 'BREAKING'
714
+ } ,
715
+ {
716
+ title : 'Refactor' ,
717
+ grep : '^refactor'
718
+ } ,
719
+ {
720
+ title : 'Style' ,
721
+ grep : '^style'
722
+ } ,
723
+ {
724
+ title : 'Test' ,
725
+ grep : '^test'
726
+ } ,
727
+ {
728
+ title : 'Chore' ,
729
+ grep : '^chore'
730
+ }
731
+ ] ;
709
732
var repo_url = 'https://github.com/owner/repo' ;
710
733
changelog . options . repo_url = repo_url ;
711
734
changelog . getProviderLinks ( ) ;
@@ -714,40 +737,25 @@ describe('git_changelog_generate.js', function() {
714
737
this . sections = changelog . organizeCommits ( this . commits , this . sections ) ;
715
738
} ) ;
716
739
717
- it ( 'should return 8 sections' , function ( ) {
718
- expect ( Object . keys ( this . sections ) . length ) . to . equal ( 8 ) ;
740
+ it ( 'should return 4 sections' , function ( ) {
741
+ expect ( this . sections . length ) . to . equal ( 4 ) ;
719
742
} ) ;
720
743
721
744
it ( 'should fix section to have 1 commit' , function ( ) {
722
- expect ( this . sections . fix . $scope . length ) . to . equal ( 1 ) ;
745
+ expect ( this . sections . find ( findItem ( 'type' , ' fix' ) ) . components . find ( findItem ( 'name' , ' $scope' ) ) . commits . length ) . to . equal ( 1 ) ;
723
746
} ) ;
724
747
725
748
it ( 'should feat section to have 1 commit' , function ( ) {
726
- expect ( this . sections . feat . $scope . length ) . to . equal ( 1 ) ;
727
- } ) ;
728
-
729
- it ( 'should breaks section to be empty' , function ( ) {
730
- expect ( this . sections . BREAKING . $scope . length ) . to . equal ( 1 ) ;
731
- } ) ;
732
-
733
- it ( 'should style section to be empty' , function ( ) {
734
- expect ( this . sections . style ) . to . deep . equal ( { } ) ;
735
- } ) ;
736
-
737
- it ( 'should refactor section be empty' , function ( ) {
738
- expect ( this . sections . refactor ) . to . deep . equal ( { } ) ;
749
+ expect ( this . sections . find ( findItem ( 'type' , 'feat' ) ) . components . find ( findItem ( 'name' , '$scope' ) ) . commits . length ) . to . equal ( 1 ) ;
739
750
} ) ;
740
751
741
- it ( 'should test section to be empty' , function ( ) {
742
- expect ( this . sections . test ) . to . deep . equal ( { } ) ;
752
+ it ( 'should breaks have 1 component and 2 comits' , function ( ) {
753
+ expect ( this . sections . find ( findItem ( 'type' , 'BREAKING' ) ) . components . length ) . to . equals ( 1 ) ;
754
+ expect ( this . sections . find ( findItem ( 'type' , 'BREAKING' ) ) . components . find ( findItem ( 'name' , '$scope' ) ) . commits . length ) . to . equal ( 1 ) ;
743
755
} ) ;
744
756
745
- it ( 'should chore section to have 1 commit' , function ( ) {
746
- expect ( this . sections . chore . $scope . length ) . to . equal ( 3 ) ;
747
- } ) ;
748
-
749
- it ( 'should docs section to be empty' , function ( ) {
750
- expect ( this . sections . docs ) . to . deep . equal ( { } ) ;
757
+ it ( 'should chore section to have 3 commit' , function ( ) {
758
+ expect ( this . sections . find ( findItem ( 'type' , 'chore' ) ) . components . find ( findItem ( 'name' , '$scope' ) ) . commits . length ) . to . equal ( 3 ) ;
751
759
} ) ;
752
760
753
761
} ) ;
0 commit comments