Skip to content

Commit

Permalink
Add skipped rounds to data.rounds when undefined data.matches
Browse files Browse the repository at this point in the history
  • Loading branch information
sbachinin committed Oct 7, 2024
1 parent 89e1cb2 commit 68122d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/draw/render_content.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ const bronze_markup = `
`

const tryExtendDataRounds = (all_data) => {
if (!all_data.matches || !all_data.rounds) return

// 1. If skippedLastRoundsCount is provided, need to add this number of items to all_data.rounds
// (all_data.rounds.length therefore becomes not an actual number of rounds but an ideal number that provides the necessary "thickness" of a tree)

Expand All @@ -26,6 +24,8 @@ const tryExtendDataRounds = (all_data) => {
() => all_data.rounds.push({})
)

if (!all_data.matches || !all_data.rounds) return

// 2. Possibly increase the "thickness" to accomodate all matches of the 1st round
// User can fail to provide data.rounds of appropriate length.
// In such case bracket will be shorter and some matches can be left unrendered
Expand Down
15 changes: 14 additions & 1 deletion tests/skippedLastRoundsCount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test(`renders normal number of rounds and matches when skippedLastRoundsCount is
})


test(`does not change the number of round elements in the DOM when skippedLastRoundsCount is specified as non-0`, () => {
test(`does not trim rounds from data.rounds`, () => {

const data = {
rounds: [{}, {}, {}],
Expand All @@ -48,6 +48,19 @@ test(`does not change the number of round elements in the DOM when skippedLastRo
expect(wrapper.querySelectorAll('.round-title').length).toBe(3)
})


test(`does not trim rounds from data.rounds when data.matches isn't provided`, () => {

const data = {
rounds: [{}, {}, {}],
skippedLastRoundsCount: 2
}
const { wrapper } = init(data)
expect(wrapper.querySelectorAll('.round-wrapper').length).toBe(3)
expect(wrapper.querySelectorAll('.round-title').length).toBe(3)
})


test(`increases the "breadth" of a tree when skippedLastRoundsCount is specified as non-0`, () => {

const data = {
Expand Down

0 comments on commit 68122d5

Please sign in to comment.