@@ -115,10 +115,11 @@ describe('Gren', () => {
115115
116116 describe ( '_groupBy, _groupByLabel' , ( ) => {
117117 it ( 'Should return the just templated issues' , ( ) => {
118- const { normal } = issues ;
118+ const { normal, noLabel } = issues ;
119119
120120 gren . options . groupBy = false ;
121121 assert . deepEqual ( gren . _groupBy ( normal ) , [ normal [ 0 ] . title ] , 'The groupBy option is false' ) ;
122+ assert . deepEqual ( gren . _groupBy ( noLabel ) , [ noLabel [ 0 ] . title ] , 'The groupBy option is false' ) ;
122123 } ) ;
123124
124125 it ( 'Should return the group based on issue labels' , ( ) => {
@@ -129,9 +130,34 @@ describe('Gren', () => {
129130 assert . deepEqual ( gren . _groupBy ( noLabel ) , [ `closed\n${ noLabel [ 0 ] . title } ` ] , 'Group option is "label" with no labels' ) ;
130131 } ) ;
131132
133+ it ( 'Should not return labels without labels' , ( ) => {
134+ const { normal, noLabel } = issues ;
135+
136+ gren . options . template . noLabel = false ;
137+ gren . options . groupBy = 'label' ;
138+
139+ assert . lengthOf ( gren . _groupBy ( noLabel ) , 0 , 'When the noLabel is false and only an issue with no labels has been passed' ) ;
140+ assert . lengthOf ( gren . _groupBy ( noLabel . concat ( normal ) ) , 1 , 'When the noLabel is false and only one issue with labels has been passed' ) ;
141+ } ) ;
142+
143+ it ( 'Should throw an error' , ( ) => {
144+ const error = chalk . red ( 'The option for groupBy is invalid, please check the documentation' ) ;
145+
146+ gren . options . groupBy = 'an unrecognised string' ;
147+ assert . throws ( gren . _groupBy . bind ( gren , issues ) , error , 'Passing an unrecognised string' ) ;
148+
149+ gren . options . groupBy = [ 1 , 2 , 3 ] ;
150+ assert . throws ( gren . _groupBy . bind ( gren , issues ) , error , 'Passing an Array' ) ;
151+
152+ gren . options . groupBy = 123 ;
153+ assert . throws ( gren . _groupBy . bind ( gren , issues ) , error , 'Passing a number' ) ;
154+ } ) ;
155+
132156 it ( 'Should group the issues based on the option' , ( ) => {
133157 const { normal, noLabel } = issues ;
134158
159+ gren . options . template . noLabel = 'closed' ;
160+
135161 gren . options . groupBy = {
136162 'Test' : [ 'enhancement' ] ,
137163 'Others' : [ 'closed' ]
0 commit comments