@@ -194,12 +194,6 @@ test("It supports multiple OpenAPI specifications on a branch", async () => {
194194 id : "main" ,
195195 name : "main" ,
196196 specifications : [ {
197- id : "foo-service.yml" ,
198- name : "foo-service.yml" ,
199- url : "/api/blob/acme/foo-openapi/foo-service.yml?ref=12345678" ,
200- editURL : "https://github.com/acme/foo-openapi/edit/main/foo-service.yml" ,
201- isDefault : false
202- } , {
203197 id : "bar-service.yml" ,
204198 name : "bar-service.yml" ,
205199 url : "/api/blob/acme/foo-openapi/bar-service.yml?ref=12345678" ,
@@ -211,6 +205,13 @@ test("It supports multiple OpenAPI specifications on a branch", async () => {
211205 url : "/api/blob/acme/foo-openapi/baz-service.yml?ref=12345678" ,
212206 editURL : "https://github.com/acme/foo-openapi/edit/main/baz-service.yml" ,
213207 isDefault : false
208+ } ,
209+ {
210+ id : "foo-service.yml" ,
211+ name : "foo-service.yml" ,
212+ url : "/api/blob/acme/foo-openapi/foo-service.yml?ref=12345678" ,
213+ editURL : "https://github.com/acme/foo-openapi/edit/main/foo-service.yml" ,
214+ isDefault : false
214215 } ] ,
215216 url : "https://github.com/acme/foo-openapi/tree/main" ,
216217 isDefault : true
@@ -663,6 +664,55 @@ test("It prioritizes main, master, develop, and development branch names when so
663664 expect ( projects [ 0 ] . versions [ 5 ] . name ) . toEqual ( "anne" )
664665} )
665666
667+ test ( "It sorts specifications alphabetically" , async ( ) => {
668+ const sut = new GitHubProjectDataSource ( {
669+ repositoryNameSuffix : "-openapi" ,
670+ repositoryDataSource : {
671+ async getRepositories ( ) {
672+ return [ {
673+ owner : "acme" ,
674+ name : "foo-openapi" ,
675+ defaultBranchRef : {
676+ id : "12345678" ,
677+ name : "main"
678+ } ,
679+ configYaml : {
680+ text : "name: Hello World"
681+ } ,
682+ branches : [ {
683+ id : "12345678" ,
684+ name : "anne" ,
685+ files : [ {
686+ name : "z-openapi.yml" ,
687+ } , {
688+ name : "a-openapi.yml" ,
689+ } , {
690+ name : "1-openapi.yml" ,
691+ } ]
692+ } ] ,
693+ tags : [ {
694+ id : "12345678" ,
695+ name : "cathrine" ,
696+ files : [ {
697+ name : "o-openapi.yml" ,
698+ } , {
699+ name : "2-openapi.yml" ,
700+ } ]
701+ } ]
702+ } ]
703+ }
704+ } ,
705+ encryptionService : noopEncryptionService ,
706+ remoteConfigEncoder : base64RemoteConfigEncoder
707+ } )
708+ const projects = await sut . getProjects ( )
709+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 0 ] . name ) . toEqual ( "1-openapi.yml" )
710+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 1 ] . name ) . toEqual ( "a-openapi.yml" )
711+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 2 ] . name ) . toEqual ( "z-openapi.yml" )
712+ expect ( projects [ 0 ] . versions [ 1 ] . specifications [ 0 ] . name ) . toEqual ( "2-openapi.yml" )
713+ expect ( projects [ 0 ] . versions [ 1 ] . specifications [ 1 ] . name ) . toEqual ( "o-openapi.yml" )
714+ } )
715+
666716test ( "It identifies the default branch in returned versions" , async ( ) => {
667717 const sut = new GitHubProjectDataSource ( {
668718 repositoryNameSuffix : "-openapi" ,
@@ -753,15 +803,15 @@ test("It adds remote versions from the project configuration", async () => {
753803 name : "Anne" ,
754804 isDefault : false ,
755805 specifications : [ {
756- id : "huey" ,
757- name : "Huey" ,
758- url : `/api/remotes/${ base64RemoteConfigEncoder . encode ( { url : "https://example.com/huey.yml" } ) } ` ,
759- isDefault : false
760- } , {
761806 id : "dewey" ,
762807 name : "Dewey" ,
763808 url : `/api/remotes/${ base64RemoteConfigEncoder . encode ( { url : "https://example.com/dewey.yml" } ) } ` ,
764809 isDefault : false
810+ } , {
811+ id : "huey" ,
812+ name : "Huey" ,
813+ url : `/api/remotes/${ base64RemoteConfigEncoder . encode ( { url : "https://example.com/huey.yml" } ) } ` ,
814+ isDefault : false
765815 } ]
766816 } , {
767817 id : "bobby" ,
0 commit comments