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) {
115
115
labels . push ( ...res . repository . labels . nodes ) ;
116
116
pageInfo = res . repository . labels . pageInfo ;
117
117
}
118
+ labels . sort ( ( l1 , l2 ) => l1 . name . localeCompare ( l2 . name ) ) ;
118
119
repo . labels = labels ;
119
120
yield repo ;
120
121
}
Original file line number Diff line number Diff line change @@ -52,6 +52,51 @@ describe('github', () => {
52
52
} ] ) ;
53
53
} ) ;
54
54
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
+
55
100
it ( 'paginated repos' , async ( ) => {
56
101
const graphql = sinon . stub ( ) ;
57
102
graphql . onCall ( 0 ) . resolves ( {
You can’t perform that action at this time.
0 commit comments