Skip to content

Commit

Permalink
Fix up ad_format tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwalley committed Aug 3, 2017
1 parent 4d31da4 commit 185ecdc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3-bumps-chart",
"version": "0.6.2",
"version": "0.6.3",
"description": "Draw bumps charts.",
"keywords": [
"d3",
Expand Down
18 changes: 17 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1323,10 +1323,25 @@ export function write_ad(event) {
let divStr = ` ${div.length} ${genderStr} Div ${roman[index]}\n`;

div.forEach((crew, crewIndex) => {
let position = crewIndex;
let currentDivision = index;
divStr += `${padEnd(renderName(crew, event.set), 25)}`;

for (let day = 0; day < event.days; day++) {
divStr += padStart(event.move[day][index][crewIndex], 4);
divStr += padStart(event.move[day][currentDivision][position], 4);
position -= event.move[day][currentDivision][position];

if (position < 0) {
currentDivision -= 1;
position += event.divisions[currentDivision].length;
}

if (position >= event.divisions[currentDivision].length) {
position -= event.divisions[currentDivision].length;
currentDivision += 1;
}
}

divStr += '\n';
});

Expand All @@ -1336,3 +1351,4 @@ export function write_ad(event) {

return ret;
}

5 changes: 3 additions & 2 deletions test/bumps-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ St John's III -4 -4 -1 -1
St Hilda's 1 1 1 1
Mansfield II -1 -1 -1 1
Wolfson III 2 1 1 1
13 *Men's Div VI
13 Men's Div VI
Exeter II -1 2 1 1
Merton II 3 1 1 1
L.M.H. II 0 1 2 1
Expand All @@ -590,7 +590,8 @@ Oriel III -2 -2 1 1
Christ Church III 0 0 0 0
S.E.H. III 2 1 1 1
Corpus Christi II 0 1 0 -2
Balliol IV 0 1 -1 1`;
Balliol IV 0 1 -1 1
`;

var expected = data;
var actual = bumps.write_ad(bumps.read_ad(data));
Expand Down

0 comments on commit 185ecdc

Please sign in to comment.