@@ -664,7 +664,7 @@ test("It prioritizes main, master, develop, and development branch names when so
664664 expect ( projects [ 0 ] . versions [ 5 ] . name ) . toEqual ( "anne" )
665665} )
666666
667- test ( "It sorts specifications alphabetically" , async ( ) => {
667+ test ( "It sorts file specifications alphabetically" , async ( ) => {
668668 const sut = new GitHubProjectDataSource ( {
669669 repositoryNameSuffix : "-openapi" ,
670670 repositoryDataSource : {
@@ -713,6 +713,45 @@ test("It sorts specifications alphabetically", async () => {
713713 expect ( projects [ 0 ] . versions [ 1 ] . specifications [ 1 ] . name ) . toEqual ( "o-openapi.yml" )
714714} )
715715
716+ test ( "It maintains remote version specification ordering from config" , async ( ) => {
717+ const sut = new GitHubProjectDataSource ( {
718+ repositoryNameSuffix : "-openapi" ,
719+ repositoryDataSource : {
720+ async getRepositories ( ) {
721+ return [ {
722+ owner : "acme" ,
723+ name : "foo-openapi" ,
724+ defaultBranchRef : {
725+ id : "12345678" ,
726+ name : "main"
727+ } ,
728+ configYaml : {
729+ text : `
730+ name: Hello World
731+ remoteVersions:
732+ - name: Bar
733+ specifications:
734+ - id: some-spec
735+ name: Zac
736+ url: https://example.com/zac.yml
737+ - id: another-spec
738+ name: Bob
739+ url: https://example.com/bob.yml
740+ `
741+ } ,
742+ branches : [ ] ,
743+ tags : [ ]
744+ } ]
745+ }
746+ } ,
747+ encryptionService : noopEncryptionService ,
748+ remoteConfigEncoder : base64RemoteConfigEncoder
749+ } )
750+ const projects = await sut . getProjects ( )
751+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 0 ] . name ) . toEqual ( "Zac" )
752+ expect ( projects [ 0 ] . versions [ 0 ] . specifications [ 1 ] . name ) . toEqual ( "Bob" )
753+ } )
754+
716755test ( "It identifies the default branch in returned versions" , async ( ) => {
717756 const sut = new GitHubProjectDataSource ( {
718757 repositoryNameSuffix : "-openapi" ,
@@ -803,15 +842,15 @@ test("It adds remote versions from the project configuration", async () => {
803842 name : "Anne" ,
804843 isDefault : false ,
805844 specifications : [ {
806- id : "dewey" ,
807- name : "Dewey" ,
808- url : `/api/remotes/${ base64RemoteConfigEncoder . encode ( { url : "https://example.com/dewey.yml" } ) } ` ,
809- isDefault : false
810- } , {
811845 id : "huey" ,
812846 name : "Huey" ,
813847 url : `/api/remotes/${ base64RemoteConfigEncoder . encode ( { url : "https://example.com/huey.yml" } ) } ` ,
814848 isDefault : false
849+ } , {
850+ id : "dewey" ,
851+ name : "Dewey" ,
852+ url : `/api/remotes/${ base64RemoteConfigEncoder . encode ( { url : "https://example.com/dewey.yml" } ) } ` ,
853+ isDefault : false
815854 } ]
816855 } , {
817856 id : "bobby" ,
0 commit comments