@@ -851,4 +851,61 @@ describe('codepush', () => {
851851 expect ( result ) . equal ( 'app-android' ) ;
852852 } ) ;
853853 } ) ;
854+
855+ describe ( 'orderPackagePaths' , ( ) => {
856+ const referencePackagePaths : PackagePath [ ] = [
857+ PackagePath . fromString (
858+ 'git+ssh://[email protected] /foo/A.git#24f0eebdd714949ec5af5366a1adcf6aeb759bdf' , 859+ ) ,
860+ PackagePath . fromString (
861+ 'git+ssh://[email protected] /foo/B.git#a4e7b1b1f4671330edac9d7ac09be66e29a56e43' , 862+ ) ,
863+ PackagePath . fromString (
864+ 'git+ssh://[email protected] /foo/C.git#09f6a4f8c19ced184bad428272b1f02f76ffd5b8' , 865+ ) ,
866+ ] ;
867+ const [ originalPkgA , originalPkgB , originalPkgC ] = referencePackagePaths ;
868+
869+ const updatedPackagedPaths : PackagePath [ ] = [
870+ PackagePath . fromString (
871+ 'git+ssh://[email protected] /foo/A.git#b554f6e7a3433f9118de8a677e34d27b161f501a' , 872+ ) ,
873+ PackagePath . fromString (
874+ 'git+ssh://[email protected] /foo/B.git#683c50cd2e50c6146f87cc377b9db1e24e722de6' , 875+ ) ,
876+ PackagePath . fromString (
877+ 'git+ssh://[email protected] /foo/C.git#9548e24c79830658be6f038177310b98298653b2' , 878+ ) ,
879+ ] ;
880+ const [ updatedPkgA , updatedPkgB , updatedPkgC ] = updatedPackagedPaths ;
881+
882+ it ( 'should preserve packages reference order' , ( ) => {
883+ const res = sut . orderPackagePaths ( referencePackagePaths , [
884+ updatedPkgC ,
885+ updatedPkgA ,
886+ updatedPkgB ,
887+ ] ) ;
888+ expect ( res ) . deep . equal ( [ updatedPkgA , updatedPkgB , updatedPkgC ] ) ;
889+ } ) ;
890+
891+ it ( 'should keep reference packages that are not updated' , ( ) => {
892+ const res = sut . orderPackagePaths ( referencePackagePaths , [
893+ updatedPkgB ,
894+ updatedPkgA ,
895+ ] ) ;
896+ expect ( res ) . deep . equal ( [ updatedPkgA , updatedPkgB , originalPkgC ] ) ;
897+ } ) ;
898+
899+ it ( 'should keep new packages that are not part of reference packages' , ( ) => {
900+ const newPkg = PackagePath . fromString (
901+ 'git+ssh://[email protected] /foo/D.git#ccf32848ae53ce9e339090bb3a1b26c971041734' , 902+ ) ;
903+ const res = sut . orderPackagePaths ( referencePackagePaths , [
904+ updatedPkgB ,
905+ updatedPkgA ,
906+ newPkg ,
907+ ] ) ;
908+ expect ( res ) . deep . equal ( [ updatedPkgA , updatedPkgB , originalPkgC , newPkg ] ) ;
909+ } ) ;
910+ } ) ;
854911} ) ;
0 commit comments