@@ -10,6 +10,12 @@ describe('Helpers', () => {
1010 assert . deepStrictEqual ( makeGroups ( [ 1 , 2 , 3 , 4 , 5 ] , 2 ) , [ [ 1 , 2 , 3 ] , [ 4 , 5 ] ] ) ;
1111 assert . deepStrictEqual ( makeGroups ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] , 2 ) , [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] ] ) ;
1212 assert . deepStrictEqual ( makeGroups ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] , 3 ) , [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 ] ] ) ;
13+ assert . deepStrictEqual ( makeGroups ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 ] , 4 ) , [
14+ [ 1 , 2 , 3 , 4 ] ,
15+ [ 5 , 6 , 7 , 8 ] ,
16+ [ 9 , 10 , 11 ] ,
17+ [ 12 , 13 , 14 ] ,
18+ ] ) ;
1319 } ) ;
1420
1521 it ( 'should make the rounds for a round-robin group' , ( ) => {
@@ -18,6 +24,17 @@ describe('Helpers', () => {
1824 assertRoundRobin ( [ 1 , 2 , 3 , 4 , 5 ] , makeRoundRobinMatches ( [ 1 , 2 , 3 , 4 , 5 ] ) ) ;
1925 assertRoundRobin ( [ 1 , 2 , 3 , 4 , 5 , 6 ] , makeRoundRobinMatches ( [ 1 , 2 , 3 , 4 , 5 , 6 ] ) ) ;
2026 } ) ;
27+
28+ it ( 'should mirror the same round order for a double round-robin group' , ( ) => {
29+ assert . deepStrictEqual ( makeRoundRobinMatches ( [ 1 , 2 , 3 , 4 ] , 'double' ) , [
30+ [ [ 1 , 4 ] , [ 3 , 2 ] ] ,
31+ [ [ 2 , 4 ] , [ 1 , 3 ] ] ,
32+ [ [ 3 , 4 ] , [ 2 , 1 ] ] ,
33+ [ [ 4 , 1 ] , [ 2 , 3 ] ] ,
34+ [ [ 4 , 2 ] , [ 3 , 1 ] ] ,
35+ [ [ 4 , 3 ] , [ 1 , 2 ] ] ,
36+ ] ) ;
37+ } ) ;
2138 } ) ;
2239
2340 describe ( 'Seed ordering methods' , ( ) => {
@@ -150,6 +167,15 @@ describe('Helpers', () => {
150167 ] ) ;
151168 } ) ;
152169
170+ it ( 'should make a snake ordering for uneven groups' , ( ) => {
171+ assert . deepStrictEqual ( ordering [ 'groups.seed_optimized' ] ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 ] , 4 ) , [
172+ 1 , 8 , 9 , 14 , // 1st group
173+ 2 , 7 , 10 , 13 , // 2nd group
174+ 3 , 6 , 11 , // 3rd group
175+ 4 , 5 , 12 , // 4th group
176+ ] ) ;
177+ } ) ;
178+
153179 it ( 'should make a bracket-optimized ordering for groups (8 seeds, 4 groups)' , ( ) => {
154180 const seeds = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ;
155181 const result = ordering [ 'groups.bracket_optimized' ] ( seeds , 4 ) ;
@@ -221,6 +247,15 @@ describe('Helpers', () => {
221247 [ 4 , 6 , 9 , 15 ] ,
222248 ] ) ;
223249 } ) ;
250+
251+ it ( 'should make a bracket-optimized ordering for groups without missing seeds' , ( ) => {
252+ const seeds = Array . from ( { length : 14 } , ( _ , i ) => i + 1 ) ;
253+ const result = ordering [ 'groups.bracket_optimized' ] ( seeds , 4 ) ;
254+
255+ assert . strictEqual ( result . length , 14 ) ;
256+ assert . isFalse ( result . includes ( undefined ) ) ;
257+ assert . deepStrictEqual ( makeGroups ( result , 4 ) . map ( group => group . length ) , [ 4 , 4 , 3 , 3 ] ) ;
258+ } ) ;
224259 } ) ;
225260
226261 describe ( 'Balance BYEs' , ( ) => {
0 commit comments