File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ async function *listRepos(org) {
156156 labels . push ( ...res . repository . labels . nodes ) ;
157157 pageInfo = res . repository . labels . pageInfo ;
158158 }
159+ labels . sort ( ( l1 , l2 ) => l1 . name . localeCompare ( l2 . name ) ) ;
159160 repo . labels = labels ;
160161 yield repo ;
161162 }
Original file line number Diff line number Diff line change @@ -105,6 +105,51 @@ describe('github', () => {
105105 } ] ) ;
106106 } ) ;
107107
108+ it ( 'labels are sorted' , async ( ) => {
109+ const graphql = sinon . stub ( ) ;
110+ graphql . resolves ( {
111+ organization : {
112+ repositories : {
113+ nodes : [
114+ {
115+ owner : { login : 'WICG' } ,
116+ name : 'speech-api' ,
117+ labels : {
118+ nodes : [ {
119+ name : 'a' ,
120+ color : 'aaaaaa' ,
121+ } , {
122+ name : 'c' ,
123+ color : 'cccccc' ,
124+ } , {
125+ name : 'b' ,
126+ color : 'bbbbbb' ,
127+ } ] ,
128+ pageInfo : { hasNextPage : false }
129+ }
130+ }
131+ ] ,
132+ pageInfo : { hasNextPage : false }
133+ }
134+ }
135+ } ) ;
136+ const github = proxyquire ( '../lib/github.js' , {
137+ './graphql.js' : graphql
138+ } ) ;
139+ const repo = ( await github . listRepos ( 'WICG' ) . next ( ) ) . value ;
140+ assert ( graphql . calledOnce ) ;
141+ assert . deepStrictEqual ( repo . labels , [ {
142+ name : 'a' ,
143+ color : 'aaaaaa' ,
144+ } , {
145+ name : 'b' ,
146+ color : 'bbbbbb' ,
147+ } , {
148+ name : 'c' ,
149+ color : 'cccccc' ,
150+ } ] ) ;
151+ } ) ;
152+
108153 it ( 'paginated repos' , async ( ) => {
109154 const graphql = sinon . stub ( ) ;
110155 graphql . onCall ( 0 ) . resolves ( {
You can’t perform that action at this time.
0 commit comments