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 @@ -115,6 +115,7 @@ async function *listRepos(org) {
115115 labels . push ( ...res . repository . labels . nodes ) ;
116116 pageInfo = res . repository . labels . pageInfo ;
117117 }
118+ labels . sort ( ( l1 , l2 ) => l1 . name . localeCompare ( l2 . name ) ) ;
118119 repo . labels = labels ;
119120 yield repo ;
120121 }
Original file line number Diff line number Diff line change @@ -52,6 +52,51 @@ describe('github', () => {
5252 } ] ) ;
5353 } ) ;
5454
55+ it ( 'labels are sorted' , async ( ) => {
56+ const graphql = sinon . stub ( ) ;
57+ graphql . resolves ( {
58+ organization : {
59+ repositories : {
60+ nodes : [
61+ {
62+ owner : { login : 'WICG' } ,
63+ name : 'speech-api' ,
64+ labels : {
65+ nodes : [ {
66+ name : 'a' ,
67+ color : 'aaaaaa' ,
68+ } , {
69+ name : 'c' ,
70+ color : 'cccccc' ,
71+ } , {
72+ name : 'b' ,
73+ color : 'bbbbbb' ,
74+ } ] ,
75+ pageInfo : { hasNextPage : false }
76+ }
77+ }
78+ ] ,
79+ pageInfo : { hasNextPage : false }
80+ }
81+ }
82+ } ) ;
83+ const github = proxyquire ( '../lib/github.js' , {
84+ './graphql.js' : graphql
85+ } ) ;
86+ const repo = ( await github . listRepos ( 'WICG' ) . next ( ) ) . value ;
87+ assert ( graphql . calledOnce ) ;
88+ assert . deepStrictEqual ( repo . labels , [ {
89+ name : 'a' ,
90+ color : 'aaaaaa' ,
91+ } , {
92+ name : 'b' ,
93+ color : 'bbbbbb' ,
94+ } , {
95+ name : 'c' ,
96+ color : 'cccccc' ,
97+ } ] ) ;
98+ } ) ;
99+
55100 it ( 'paginated repos' , async ( ) => {
56101 const graphql = sinon . stub ( ) ;
57102 graphql . onCall ( 0 ) . resolves ( {
You can’t perform that action at this time.
0 commit comments