@@ -199,7 +199,6 @@ describe('AssemblyValidationService', () => {
199
199
. WithName ( 'club 1' )
200
200
. WithTeam (
201
201
teamB
202
- . WithTeamNumber ( 2 )
203
202
. WithPlayer ( player777B , TeamMembershipType . REGULAR )
204
203
. WithPlayer ( player888B , TeamMembershipType . REGULAR )
205
204
. WithPlayer ( player999B , TeamMembershipType . REGULAR )
@@ -760,7 +759,8 @@ describe('AssemblyValidationService', () => {
760
759
let player888 : Player ;
761
760
let player999 : Player ;
762
761
763
- let team : Team ;
762
+ let team1 : Team ;
763
+ let team2 : Team ;
764
764
765
765
beforeEach ( async ( ) => {
766
766
const player555B = PlayerBuilder . Create ( )
@@ -823,30 +823,41 @@ describe('AssemblyValidationService', () => {
823
823
. WithDate ( new Date ( '2020-05-09' ) ) ,
824
824
) ;
825
825
826
- const teamB = TeamBuilder . Create ( SubEventTypeEnum . MX )
826
+ const team1B = TeamBuilder . Create ( SubEventTypeEnum . MX )
827
827
. WithTeamNumber ( 1 )
828
828
. WithSeason ( event . season )
829
829
. WithName ( 'team 1' ) ;
830
+ const team2B = TeamBuilder . Create ( SubEventTypeEnum . MX )
831
+ . WithTeamNumber ( 2 )
832
+ . WithSeason ( event . season )
833
+ . WithName ( 'team 2' ) ;
834
+
835
+ const entry = EventCompetitionEntryBuilder . Create ( 'competition' )
836
+ . WithDrawId ( draw . id )
837
+ . WithSubEventId ( subEvent . id )
838
+ . WithBasePlayer ( player666B , 6 , 6 , 6 )
839
+ . WithBasePlayer ( player777B , 7 , 7 , 7 )
840
+ . WithBasePlayer ( player888B , 8 , 8 , 8 )
841
+ . WithBasePlayer ( player999B , 9 , 9 , 9 )
842
+ . WithBaseIndex ( 60 ) ;
830
843
831
844
await ClubBuilder . Create ( )
832
845
. WithName ( 'club 1' )
833
846
. WithTeam (
834
- teamB
835
- . WithTeamNumber ( 2 )
847
+ team1B
836
848
. WithPlayer ( player777B , TeamMembershipType . REGULAR )
837
849
. WithPlayer ( player888B , TeamMembershipType . REGULAR )
838
850
. WithPlayer ( player999B , TeamMembershipType . REGULAR )
839
851
. WithPlayer ( player666B , TeamMembershipType . REGULAR )
840
- . WithEntry (
841
- EventCompetitionEntryBuilder . Create ( 'competition' )
842
- . WithDrawId ( draw . id )
843
- . WithSubEventId ( subEvent . id )
844
- . WithBasePlayer ( player666B , 6 , 6 , 6 )
845
- . WithBasePlayer ( player777B , 7 , 7 , 7 )
846
- . WithBasePlayer ( player888B , 8 , 8 , 8 )
847
- . WithBasePlayer ( player999B , 9 , 9 , 9 )
848
- . WithBaseIndex ( 60 ) ,
849
- ) ,
852
+ . WithEntry ( entry ) ,
853
+ )
854
+ . WithTeam (
855
+ team2B
856
+ . WithPlayer ( player777B , TeamMembershipType . REGULAR )
857
+ . WithPlayer ( player888B , TeamMembershipType . REGULAR )
858
+ . WithPlayer ( player999B , TeamMembershipType . REGULAR )
859
+ . WithPlayer ( player666B , TeamMembershipType . REGULAR )
860
+ . WithEntry ( entry ) ,
850
861
)
851
862
. Build ( ) ;
852
863
@@ -856,7 +867,8 @@ describe('AssemblyValidationService', () => {
856
867
player888 = await player888B . Build ( ) ;
857
868
player999 = await player999B . Build ( ) ;
858
869
859
- team = await teamB . Build ( ) ;
870
+ team1 = await team1B . Build ( ) ;
871
+ team2 = await team2B . Build ( ) ;
860
872
} ) ;
861
873
describe ( 'Rule [PlayerOrderRule]' , ( ) => {
862
874
beforeEach ( async ( ) => {
@@ -870,7 +882,7 @@ describe('AssemblyValidationService', () => {
870
882
it ( 'Double 3 is better then Double 4' , async ( ) => {
871
883
const validation = await service . validate ( {
872
884
systemId : system . id ,
873
- teamId : team ?. id ,
885
+ teamId : team1 ?. id ,
874
886
encounterId : encounter . id ,
875
887
double3 : [ player666 . id , player999 . id ] ,
876
888
double4 : [ player777 . id , player888 . id ] ,
@@ -895,7 +907,7 @@ describe('AssemblyValidationService', () => {
895
907
test . each ( invalid ) ( 'Single %p is not better then Single %p' , async ( p1 , p2 ) => {
896
908
const validation = await service . validate ( {
897
909
systemId : system . id ,
898
- teamId : team ?. id ,
910
+ teamId : team1 ?. id ,
899
911
encounterId : encounter . id ,
900
912
[ `single${ p1 } ` ] : player888 . id ,
901
913
[ `single${ p2 } ` ] : player777 . id ,
@@ -920,7 +932,7 @@ describe('AssemblyValidationService', () => {
920
932
it ( 'Mixed double is better then other' , async ( ) => {
921
933
const validation = await service . validate ( {
922
934
systemId : system . id ,
923
- teamId : team ?. id ,
935
+ teamId : team1 ?. id ,
924
936
encounterId : encounter . id ,
925
937
double3 : [ player777 . id , player888 . id ] ,
926
938
double4 : [ player666 . id , player888 . id ] ,
@@ -951,7 +963,7 @@ describe('AssemblyValidationService', () => {
951
963
it ( 'Mixed double is better then other by level' , async ( ) => {
952
964
const validation = await service . validate ( {
953
965
systemId : system . id ,
954
- teamId : team ?. id ,
966
+ teamId : team1 ?. id ,
955
967
encounterId : encounter . id ,
956
968
double3 : [ player777 . id , player888 . id ] ,
957
969
double4 : [ player666 . id , player999 . id ] ,
@@ -993,7 +1005,7 @@ describe('AssemblyValidationService', () => {
993
1005
it ( 'should be valid doubles' , async ( ) => {
994
1006
const validation = await service . validate ( {
995
1007
systemId : system . id ,
996
- teamId : team ?. id ,
1008
+ teamId : team1 ?. id ,
997
1009
encounterId : encounter . id ,
998
1010
double1 : [ player666 . id , player888 . id ] ,
999
1011
double2 : [ player777 . id , player999 . id ] ,
@@ -1015,7 +1027,7 @@ describe('AssemblyValidationService', () => {
1015
1027
it ( 'should be invalid if the player has more then 1 mixed' , async ( ) => {
1016
1028
const validation = await service . validate ( {
1017
1029
systemId : system . id ,
1018
- teamId : team ?. id ,
1030
+ teamId : team1 ?. id ,
1019
1031
encounterId : encounter . id ,
1020
1032
double3 : [ player666 . id , player999 . id ] ,
1021
1033
double4 : [ player888 . id , player999 . id ] ,
@@ -1046,7 +1058,7 @@ describe('AssemblyValidationService', () => {
1046
1058
it ( 'should be valid doubles' , async ( ) => {
1047
1059
const validation = await service . validate ( {
1048
1060
systemId : system . id ,
1049
- teamId : team ?. id ,
1061
+ teamId : team1 ?. id ,
1050
1062
encounterId : encounter . id ,
1051
1063
double1 : [ player666 . id , player777 . id ] ,
1052
1064
double2 : [ player888 . id , player999 . id ] ,
@@ -1070,7 +1082,7 @@ describe('AssemblyValidationService', () => {
1070
1082
it ( 'should be invalid if a mixed 3 has 2 of the same gender' , async ( ) => {
1071
1083
const validation = await service . validate ( {
1072
1084
systemId : system . id ,
1073
- teamId : team ?. id ,
1085
+ teamId : team1 ?. id ,
1074
1086
encounterId : encounter . id ,
1075
1087
double3 : [ player666 . id , player777 . id ] ,
1076
1088
double4 : [ player888 . id , player777 . id ] ,
@@ -1091,7 +1103,7 @@ describe('AssemblyValidationService', () => {
1091
1103
it ( 'should be invalid if a mixed 4 has 2 of the same gender' , async ( ) => {
1092
1104
const validation = await service . validate ( {
1093
1105
systemId : system . id ,
1094
- teamId : team ?. id ,
1106
+ teamId : team1 ?. id ,
1095
1107
encounterId : encounter . id ,
1096
1108
double3 : [ player666 . id , player999 . id ] ,
1097
1109
double4 : [ player888 . id , player999 . id ] ,
@@ -1123,7 +1135,7 @@ describe('AssemblyValidationService', () => {
1123
1135
it ( 'should be valid' , async ( ) => {
1124
1136
const validation = await service . validate ( {
1125
1137
systemId : system . id ,
1126
- teamId : team ?. id ,
1138
+ teamId : team2 ?. id ,
1127
1139
encounterId : encounter . id ,
1128
1140
single1 : player666 . id ,
1129
1141
single2 : player777 . id ,
@@ -1138,13 +1150,32 @@ describe('AssemblyValidationService', () => {
1138
1150
) ;
1139
1151
expect ( error ) . toBeUndefined ( ) ;
1140
1152
} ) ;
1153
+
1154
+ it ( 'first team should always be valid' , async ( ) => {
1155
+ const validation = await service . validate ( {
1156
+ systemId : system . id ,
1157
+ teamId : team1 ?. id ,
1158
+ encounterId : encounter . id ,
1159
+ single1 : player555 . id ,
1160
+ single2 : player777 . id ,
1161
+ single3 : player888 . id ,
1162
+ single4 : player999 . id ,
1163
+ } ) ;
1164
+
1165
+ expect ( validation ) . toBeDefined ( ) ;
1166
+
1167
+ const error = validation . errors ?. find (
1168
+ ( e ) => e . message === 'all.competition.team-assembly.errors.player-min-level' ,
1169
+ ) ;
1170
+ expect ( error ) . toBeUndefined ( ) ;
1171
+ } ) ;
1141
1172
} ) ;
1142
1173
1143
1174
describe ( 'invalid' , ( ) => {
1144
- it ( " should be invalid if the player doesn't have competition status on true " , async ( ) => {
1175
+ it ( ' should be invalid if the player has a lower ranking then the subevent ' , async ( ) => {
1145
1176
const validation = await service . validate ( {
1146
1177
systemId : system . id ,
1147
- teamId : team ?. id ,
1178
+ teamId : team2 ?. id ,
1148
1179
encounterId : encounter . id ,
1149
1180
single1 : player555 . id ,
1150
1181
single2 : player777 . id ,
@@ -1604,7 +1635,6 @@ describe('AssemblyValidationService', () => {
1604
1635
. WithName ( 'club 1' )
1605
1636
. WithTeam (
1606
1637
teamB
1607
- . WithTeamNumber ( 2 )
1608
1638
. WithPlayer ( player777B , TeamMembershipType . REGULAR )
1609
1639
. WithPlayer ( player888B , TeamMembershipType . REGULAR )
1610
1640
. WithPlayer ( player999B , TeamMembershipType . REGULAR )
0 commit comments