Bodyweight work, logged the way it is done
A push-up has no weight to type and the app asked for one anyway, on a quarter of the catalogue. Issues #31, #32 and #33 are the same gap seen from three sides: the app assumed progress lived in the load. Two flags on the exercise config rather than two new modes, because "bodyweight" and "per side" are equally true of a rep set and a timed hold: bodyweight — seeded from the equipment the dataset already records. The weight column is gone, the set row is one stepper, and the working-weight prompt stops asking about a weight that was never there. A belt weight reads as an addition and hands progression back to the normal policies, because now there is something to add. side — 8 logged is 8 per side. The total is spelled out where there is width for it, and volume counts both sides so a routine that moved to single-arm work no longer halves itself on the chart. Bodyweight progression grows reps, and now sets: a rep ceiling sends the reps back to the bottom and adds a set instead of climbing forever, stopping at six with the advice it should have given all along. No ceiling keeps the old behaviour exactly. Both flags are written to a plan only when they disagree with the catalogue, and absent reads as false, so every existing plan, workout and backup is read unchanged.
This commit is contained in:
1 parent
8de55ce0d9
commit
c33ff15d9d
20 files changed
+524
-44
No files matched your search
@@ -37,6 +37,13 @@ export const gifSrc = ex => GIF_BASE + ex.gif
|
||||
// Cardio exercises log time + speed instead of weight × reps.
|
||||
export const isCardio = idOrEx => (typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx)?.bp === 'cardio'
|
||||
|
||||
// Exercises the dataset already knows carry no external load (issue #32) — a quarter of the
|
||||
// catalogue. This seeds the `bw` flag on a fresh config so a push-up never asks for a weight
|
||||
// nobody was going to enter. It is only the default: the flag lives on the config, so a dip
|
||||
// done with a belt can turn it off and a custom exercise can turn it on.
|
||||
export const isBodyweightEq = idOrEx =>
|
||||
(typeof idOrEx === 'string' ? EXIDX[idOrEx] : idOrEx)?.eq === 'body weight'
|
||||
|
||||
// An id that resolves to nothing — a plan file built against a different exercise dataset,
|
||||
// a custom exercise deleted on another device before the sync arrived — still has to
|
||||
// render. A placeholder keeps it visible (and removable) instead of taking the whole view
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Pure helpers over the state object S (ported 1:1 from the vanilla app).
|
||||
import { todayISO, isoOf, weekKey, fmtNum } from './format.js'
|
||||
import { isCardio } from './exercises.js'
|
||||
import { isCardio, isBodyweightEq } from './exercises.js'
|
||||
import { t } from './i18n.js'
|
||||
|
||||
// How an exercise is logged (issue #16). This used to be derived from the body part alone,
|
||||
// which meant a plank or a farmer's carry could only be timed by filing it under cardio.
|
||||
@@ -17,6 +18,25 @@ export function modeOf(cfg) {
|
||||
}
|
||||
export const isTimed = cfg => modeOf(cfg) === 'time'
|
||||
|
||||
// Two flags that ride on top of a mode rather than making new ones (issues #31/#32), because
|
||||
// "bodyweight" and "per side" are true of a rep set and of a timed hold alike:
|
||||
// bodyweight — the exercise carries no load of its own, so `w` means *added* weight and is
|
||||
// asked for only once you say there is some. Seeded from the equipment field.
|
||||
// Spelled out rather than `bw`, which a workout already uses for the weigh-in
|
||||
// it was logged at — two different things one letter apart is a bug waiting.
|
||||
// side — the logged reps are what one side did: 8 logged is 8 per side, 16 in total.
|
||||
// Both are absent on every plan, workout and backup written before they existed, and absent
|
||||
// reads as false, so nothing needs migrating.
|
||||
export const isBw = cfg => (cfg && cfg.bodyweight != null ? !!cfg.bodyweight : isBodyweightEq(cfg && cfg.id))
|
||||
export const isPerSide = cfg => !!(cfg && cfg.side)
|
||||
// Reps as they are counted rather than as they are logged. Only this function knows that a
|
||||
// per-side set is worth double, so stats and volume cannot disagree with the set row.
|
||||
export const totalReps = (cfg, reps) => (isPerSide(cfg) ? 2 : 1) * (reps || 0)
|
||||
// Reps as they are written on a row: "8" bilateral, "8/side" unilateral. The total is left
|
||||
// off here — a set row is already narrow, and "8/side · 16 total" belongs in the one place
|
||||
// that has the width for it (the exercise line), not repeated down every row.
|
||||
export const repLabel = (cfg, reps) => (isPerSide(cfg) ? t('{0}/side', reps) : String(reps))
|
||||
|
||||
// mm:ss for a work duration — seconds alone read badly past a minute ("90 s" vs "1:30").
|
||||
export function fmtSec(sec) {
|
||||
const n = Math.max(0, Math.round(Number(sec) || 0))
|
||||
@@ -69,27 +89,41 @@ const effortTail = s => {
|
||||
// One-line summary of a logged set. `cfg` carries the mode when the caller has it (a routine
|
||||
// entry or a workout entry); passing an id alone keeps the old body-part behaviour.
|
||||
export function setLabel(id, s, cfg) {
|
||||
const mode = modeOf(cfg || { id })
|
||||
const c = cfg || { id }
|
||||
const mode = modeOf(c)
|
||||
if (mode === 'cardio') return `${s.min || 0} min @ ${fmtNum(s.speed || 0)} km/h`
|
||||
if (mode === 'time') return fmtSec(s.sec) + (s.w > 0 ? ` · ${fmtNum(s.w)}` : '')
|
||||
return `${fmtNum(s.w || 0)}×${s.r || 0}` + effortTail(s)
|
||||
// Bodyweight reads as what you did — "12", or "+10 × 12" once there is a belt involved —
|
||||
// rather than "0×12", which says a set was performed with no weight and means nothing.
|
||||
const reps = repLabel(c, s.r || 0)
|
||||
if (isBw({ ...c, id: c.id ?? id })) {
|
||||
const load = s.w > 0 ? `+${fmtNum(s.w)} × ` : ''
|
||||
return `${load}${reps}` + effortTail(s)
|
||||
}
|
||||
return `${fmtNum(s.w || 0)}×${reps}` + effortTail(s)
|
||||
}
|
||||
// Default config for a freshly added exercise.
|
||||
export function defaultConfig(id, mode) {
|
||||
const m = mode || modeOf({ id })
|
||||
if (m === 'cardio') return { sets: 1, min: 20, speed: 8 }
|
||||
if (m === 'time') return { sets: 3, sec: 45, weight: 0, mode: 'time' }
|
||||
return { sets: 3, reps: 10, weight: 0, mode: 'reps' }
|
||||
// Written only when it is true, so a barbell config is byte-for-byte what it was before
|
||||
// the flag existed and a plan file gains nothing it does not need.
|
||||
const bw = isBodyweightEq(id) ? { bodyweight: true } : {}
|
||||
if (m === 'time') return { sets: 3, sec: 45, weight: 0, mode: 'time', ...bw }
|
||||
return { sets: 3, reps: 10, weight: 0, mode: 'reps', ...bw }
|
||||
}
|
||||
// One-line summary of a planned exercise ("3 × 10 · 60 kg"), shared by the routine editor
|
||||
// and the plan export so a mode is described the same way everywhere.
|
||||
export function exLine(cfg, unit) {
|
||||
const mode = modeOf(cfg)
|
||||
const n = cfg.sets || 1
|
||||
const load = cfg.weight ? ' · ' + fmtNum(cfg.weight) + ' ' + unit : ''
|
||||
// Added weight reads as added: "+10 kg" on a dip belt, "60 kg" on a barbell.
|
||||
const load = cfg.weight ? ' · ' + (isBw(cfg) ? '+' : '') + fmtNum(cfg.weight) + ' ' + unit : ''
|
||||
if (mode === 'cardio') return `${n} × ${cfg.min || 20} min @ ${fmtNum(cfg.speed || 8)} km/h`
|
||||
if (mode === 'time') return `${n} × ${fmtSec(cfg.sec || 45)}${load}`
|
||||
return `${n} × ${cfg.reps}${load}`
|
||||
// This is the line with room for the arithmetic, so per side spells it out in full.
|
||||
const total = isPerSide(cfg) ? ' · ' + t('{0} in total', totalReps(cfg, cfg.reps) * n) : ''
|
||||
return `${n} × ${repLabel(cfg, cfg.reps)}${load}${total}`
|
||||
}
|
||||
|
||||
// Drop superset ids that no longer have an adjacent partner (after unlink/reorder/remove).
|
||||
@@ -166,7 +200,9 @@ export function buildSets(S, cfg) {
|
||||
}
|
||||
export function workoutVolume(w) {
|
||||
let v = 0
|
||||
w.entries.forEach(e => e.sets.forEach(s => { if (s.done) v += (s.w || 0) * (s.r || 0) }))
|
||||
// A per-side set moved its load twice, so it counts twice — otherwise a routine that
|
||||
// switched to single-arm rows would show as half the work for the same session.
|
||||
w.entries.forEach(e => e.sets.forEach(s => { if (s.done) v += (s.w || 0) * totalReps(e.target, s.r) }))
|
||||
return v
|
||||
}
|
||||
export function setsDone(w) {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, exLine, workoutVolume, effortOf, stepEffort, capEffort } from './history.js'
|
||||
import { modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, exLine, workoutVolume, effortOf, stepEffort, capEffort, isBw, isPerSide, totalReps } from './history.js'
|
||||
import { EXDB } from './exercises.js'
|
||||
|
||||
// Real ids out of the shipped catalogue, so the body-part fallback is exercised for real.
|
||||
const CARDIO = EXDB.find(e => e.bp === 'cardio').id
|
||||
const LIFT = EXDB.find(e => e.bp !== 'cardio').id
|
||||
// A *loaded* lift: the catalogue's first non-cardio entry is a sit-up, which since issue #32
|
||||
// defaults to bodyweight and would quietly send every label test down the other path.
|
||||
const LIFT = EXDB.find(e => e.bp !== 'cardio' && e.eq !== 'body weight').id
|
||||
const BW = EXDB.find(e => e.eq === 'body weight').id
|
||||
|
||||
describe('modeOf', () => {
|
||||
it('falls back to the body part when a plan has no mode — every existing plan keeps working', () => {
|
||||
@@ -255,9 +258,57 @@ describe('defaultConfig', () => {
|
||||
expect(defaultConfig(CARDIO)).toEqual({ sets: 1, min: 20, speed: 8 })
|
||||
expect(defaultConfig(LIFT, 'time')).toEqual({ sets: 3, sec: 45, weight: 0, mode: 'time' })
|
||||
})
|
||||
it('seeds the bodyweight flag from the catalogue, and only when it is true', () => {
|
||||
expect(defaultConfig(BW)).toEqual({ sets: 3, reps: 10, weight: 0, mode: 'reps', bodyweight: true })
|
||||
expect(defaultConfig(BW, 'time')).toEqual({ sets: 3, sec: 45, weight: 0, mode: 'time', bodyweight: true })
|
||||
expect('bodyweight' in defaultConfig(LIFT)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
/* ---------- bodyweight and per side (issues #31/#32/#33) ---------- */
|
||||
|
||||
describe('isBw', () => {
|
||||
it('defaults from the catalogue so an existing plan needs no flag', () => {
|
||||
expect(isBw({ id: BW })).toBe(true)
|
||||
expect(isBw({ id: LIFT })).toBe(false)
|
||||
})
|
||||
it('lets the config win in both directions — a belt on a dip, a flag on a machine', () => {
|
||||
expect(isBw({ id: BW, bodyweight: false })).toBe(false)
|
||||
expect(isBw({ id: LIFT, bodyweight: true })).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('totalReps', () => {
|
||||
it('doubles a per-side set and leaves a bilateral one alone', () => {
|
||||
expect(totalReps({ side: true }, 8)).toBe(16)
|
||||
expect(totalReps({}, 8)).toBe(8)
|
||||
expect(totalReps({ side: true }, 0)).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('setLabel — bodyweight', () => {
|
||||
it('reads as reps alone, because "0×12" describes nothing', () => {
|
||||
expect(setLabel(BW, { w: 0, r: 12 }, { id: BW })).toBe('12')
|
||||
})
|
||||
it('spells out a belt as an addition', () => {
|
||||
expect(setLabel(BW, { w: 10, r: 8 }, { id: BW })).toBe('+10 × 8')
|
||||
})
|
||||
it('marks a per-side set on both paths', () => {
|
||||
expect(setLabel(BW, { w: 0, r: 8 }, { id: BW, side: true })).toBe('8/side')
|
||||
expect(setLabel(LIFT, { w: 20, r: 8 }, { id: LIFT, side: true })).toBe('20×8/side')
|
||||
})
|
||||
it('keeps the effort tail', () => {
|
||||
expect(setLabel(BW, { w: 0, r: 12, rir: 2 }, { id: BW })).toBe('12 (RIR 2)')
|
||||
})
|
||||
})
|
||||
|
||||
describe('exLine', () => {
|
||||
it('shows the per-side arithmetic where there is room for it', () => {
|
||||
expect(exLine({ id: LIFT, sets: 3, reps: 8, side: true }, 'kg')).toBe('3 × 8/side · 48 in total')
|
||||
})
|
||||
it('marks added weight as added', () => {
|
||||
expect(exLine({ id: BW, sets: 3, reps: 8, weight: 10 }, 'kg')).toBe('3 × 8 · +10 kg')
|
||||
})
|
||||
it('summarises a planned exercise per mode', () => {
|
||||
expect(exLine({ id: LIFT, sets: 3, reps: 10 }, 'kg')).toBe('3 × 10')
|
||||
expect(exLine({ id: LIFT, sets: 3, reps: 10, weight: 60 }, 'kg')).toBe('3 × 10 · 60 kg')
|
||||
@@ -318,4 +369,14 @@ describe('workoutVolume', () => {
|
||||
] }
|
||||
expect(workoutVolume(w)).toBe(600)
|
||||
})
|
||||
|
||||
it('counts a per-side set twice — the load moved twice (issue #31)', () => {
|
||||
const w = { entries: [{ id: LIFT, target: { side: true }, sets: [{ w: 20, r: 8, done: true }] }] }
|
||||
expect(workoutVolume(w)).toBe(320)
|
||||
})
|
||||
|
||||
it('leaves an unloaded bodyweight set at zero volume rather than inventing a number', () => {
|
||||
const w = { entries: [{ id: BW, target: { bodyweight: true }, sets: [{ w: 0, r: 20, done: true }] }] }
|
||||
expect(workoutVolume(w)).toBe(0)
|
||||
})
|
||||
})
|
||||
@@ -8,8 +8,8 @@
|
||||
// 2. A clean, printable page (Save as PDF) where a single exercise never splits across
|
||||
// a page break — each exercise, and each routine that fits, stays in one place.
|
||||
|
||||
import { EXIDX } from './exercises.js'
|
||||
import { modeOf, fmtSec } from './history.js'
|
||||
import { EXIDX, isBodyweightEq } from './exercises.js'
|
||||
import { modeOf, fmtSec, isBw, repLabel } from './history.js'
|
||||
import { uid, todayISO, DAYN, fmtNum, exCount } from './format.js'
|
||||
import { t } from './i18n.js'
|
||||
|
||||
@@ -33,11 +33,16 @@ function cleanEx(e) {
|
||||
if (e.reps != null) o.reps = e.reps
|
||||
if (e.weight) o.weight = e.weight
|
||||
}
|
||||
// How the exercise is logged travels too (issues #31/#32) — the bodyweight flag only when
|
||||
// it disagrees with the catalogue, since agreeing is what the other end already assumes.
|
||||
if (e.bodyweight != null && e.bodyweight !== isBodyweightEq(e.id)) o.bodyweight = e.bodyweight
|
||||
if (e.side) o.side = true
|
||||
// Progression settings travel with the plan — a shared Greyskull routine that arrives
|
||||
// without its rule is just a list of weights.
|
||||
if (e.prog) o.prog = e.prog
|
||||
if (e.inc > 0) o.inc = e.inc
|
||||
if (e.repsMin != null) o.repsMin = e.repsMin
|
||||
if (e.repsMax != null) o.repsMax = e.repsMax
|
||||
if (e.sg) o.sg = e.sg
|
||||
return o
|
||||
}
|
||||
@@ -144,8 +149,8 @@ function scheme(e, unit) {
|
||||
const body = `${e.min || 20} min @ ${fmtNum(e.speed || 8)} km/h`
|
||||
return sets > 1 ? `${sets} × ${body}` : body
|
||||
}
|
||||
let s = mode === 'time' ? `${sets} × ${fmtSec(e.sec || 45)}` : `${sets} × ${e.reps ?? 10}`
|
||||
if (e.weight) s += ` · ${fmtNum(e.weight)} ${unit}`
|
||||
let s = mode === 'time' ? `${sets} × ${fmtSec(e.sec || 45)}` : `${sets} × ${repLabel(e, e.reps ?? 10)}`
|
||||
if (e.weight) s += ` · ${isBw(e) ? '+' : ''}${fmtNum(e.weight)} ${unit}`
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ export function defaultIncrement(exId, unit) {
|
||||
return heavy ? 5 : 2.5
|
||||
}
|
||||
export const DEFAULT_SEC_INCREMENT = 5
|
||||
// Where adding another set of push-ups stops being progress and starts being a way to spend
|
||||
// an evening. Past this the honest advice is load or a harder variation (issue #33).
|
||||
export const MAX_BW_SETS = 6
|
||||
|
||||
// The policy in force for one exercise: its own override, else the routine's default, else
|
||||
// the mode's default. Reps keeps behaving the way the app always did (all reps → add a step).
|
||||
@@ -117,6 +120,7 @@ export function readSession(entry, fallback) {
|
||||
return {
|
||||
mode, goal, reps,
|
||||
weight: Math.max(0, ...sets.filter(s => s.done).map(s => s.w || 0)),
|
||||
count: reps.length, // the dimension bodyweight work grows (#33)
|
||||
low: reps.length ? Math.min(...reps) : 0,
|
||||
amrap: reps.length ? reps[reps.length - 1] : 0, // Greyskull's final set
|
||||
ok: goal > 0 && enough && reps.length > 0 && reps.every(r => r >= goal)
|
||||
@@ -179,14 +183,26 @@ export function nextPrescription(S, cfg, routine) {
|
||||
|
||||
const w = last.weight
|
||||
// Bodyweight work carries no external load, so there is nothing to add or take away —
|
||||
// "deload your push-ups to 2.5 kg" is not advice. Progress in reps instead. This runs
|
||||
// ahead of the individual policies because it is true for all of them; a rep range set on
|
||||
// top of it simply gets passed once you exceed it, which is the right moment to add load
|
||||
// or move to a harder variation anyway.
|
||||
// "deload your push-ups to 2.5 kg" is not advice. Progress in reps instead. This runs ahead
|
||||
// of the individual policies because it is true for all of them. Note the trigger is the
|
||||
// *logged* weight, not the `bw` flag: a dip done with a belt has a load to progress and
|
||||
// belongs on the normal policies, and a barbell lift logged at 0 has nothing to add to.
|
||||
if (w <= 0) {
|
||||
const goal = last.goal || cfg.reps || 0
|
||||
if (last.ok && goal > 0) return { policy, kind: 'up', weight: 0, reps: goal + 1, why: ['Bodyweight — every rep last time, so go for {0} this time.', goal + 1] }
|
||||
return { policy, kind: 'hold', weight: 0, reps: goal || undefined, why: ['Bodyweight — same target again until every set is clean.'] }
|
||||
if (!last.ok || goal <= 0) return { policy, kind: 'hold', weight: 0, reps: goal || undefined, why: ['Bodyweight — same target again until every set is clean.'] }
|
||||
// A ceiling turns "+1 rep forever" into a plan (issue #33). Past the top of the range the
|
||||
// reps go back to the bottom and a set is added instead, which is how bodyweight work
|
||||
// actually progresses once a set of 30 push-ups stops being a strength stimulus.
|
||||
const top = cfg.repsMax > 0 ? cfg.repsMax : 0
|
||||
if (top > 0 && goal >= top) {
|
||||
const sets = Math.max(1, cfg.sets || last.count || 1) + 1
|
||||
const bottom = Math.max(1, Math.min(cfg.reps || top, top))
|
||||
if (sets <= MAX_BW_SETS) return { policy, kind: 'up', weight: 0, reps: bottom, sets, why: ['{0} reps in every set — add a set and go back to {1}.', goal, bottom] }
|
||||
// Out of sets worth adding: more volume is no longer the answer, load or a harder
|
||||
// variation is — and that is a decision for a person, not a policy.
|
||||
return { policy, kind: 'hold', weight: 0, reps: goal, why: ['{0} sets of {1} — time to add weight or move to a harder variation.', sets - 1, goal] }
|
||||
}
|
||||
return { policy, kind: 'up', weight: 0, reps: goal + 1, why: ['Bodyweight — every rep last time, so go for {0} this time.', goal + 1] }
|
||||
}
|
||||
if (policy === 'double') {
|
||||
const top = cfg.reps || last.goal || 10
|
||||
@@ -231,12 +247,20 @@ export function nextPrescription(S, cfg, routine) {
|
||||
*/
|
||||
export function applyPrescription(sets, p) {
|
||||
if (!p || p.kind === 'off' || p.kind === 'first') return sets
|
||||
return sets.map(s => {
|
||||
const out = sets.map(s => {
|
||||
if (s.done) return s
|
||||
const out = { ...s }
|
||||
if (p.weight != null) out.w = p.weight
|
||||
if (p.reps != null) out.r = p.reps
|
||||
if (p.sec != null) out.sec = p.sec
|
||||
return out
|
||||
const o = { ...s }
|
||||
if (p.weight != null) o.w = p.weight
|
||||
if (p.reps != null) o.r = p.reps
|
||||
if (p.sec != null) o.sec = p.sec
|
||||
return o
|
||||
})
|
||||
// A policy that decided on a set count gets to grow the list — bodyweight progression adds
|
||||
// a set where a barbell would have added a plate. Only ever upwards, and only by copying a
|
||||
// row that is already there: a session in progress must not lose a set it has logged.
|
||||
if (p.sets > out.length) {
|
||||
const seed = out[out.length - 1]
|
||||
while (out.length < p.sets) out.push({ ...seed, done: false })
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import {
|
||||
readSession, sessionsFor, stallCount, nextPrescription, applyPrescription,
|
||||
policyFor, defaultIncrement, POLICIES_FOR, DELOAD_AFTER
|
||||
policyFor, defaultIncrement, POLICIES_FOR, DELOAD_AFTER, MAX_BW_SETS
|
||||
} from './progression.js'
|
||||
import { EXDB } from './exercises.js'
|
||||
|
||||
@@ -189,6 +189,47 @@ describe('bodyweight exercises', () => {
|
||||
expect(p.reps).toBe(11)
|
||||
})
|
||||
|
||||
/* A ceiling turns "+1 rep forever" into a plan — issue #33. */
|
||||
it('climbs to the ceiling one rep at a time', () => {
|
||||
const p = nextPrescription(bw([[0, 10, 10, 10]]), { ...cfg, repsMax: 15 })
|
||||
expect(p.kind).toBe('up')
|
||||
expect(p.reps).toBe(11)
|
||||
expect(p.sets).toBeUndefined()
|
||||
})
|
||||
|
||||
it('adds a set and restarts the range once the ceiling is reached', () => {
|
||||
const at15 = hist(LIFT, [[0, 15, 15, 15]], { sets: 3, reps: 15 })
|
||||
const p = nextPrescription(at15, { ...cfg, reps: 10, repsMax: 15 })
|
||||
expect(p.kind).toBe('up')
|
||||
expect(p.sets).toBe(4)
|
||||
expect(p.reps).toBe(10)
|
||||
expect(p.weight).toBe(0)
|
||||
})
|
||||
|
||||
it('stops adding sets at the cap and says what to do instead', () => {
|
||||
const at15 = hist(LIFT, [[0, 15, 15, 15]], { sets: 3, reps: 15 })
|
||||
const p = nextPrescription(at15, { ...cfg, sets: MAX_BW_SETS, reps: 10, repsMax: 15 })
|
||||
expect(p.kind).toBe('hold')
|
||||
expect(p.sets).toBeUndefined()
|
||||
expect(p.why[0]).toMatch(/harder variation/)
|
||||
})
|
||||
|
||||
it('leaves a belted set to the normal policies — there is a load to add now', () => {
|
||||
const belted = hist(LIFT, [[10, 10, 10, 10]], { sets: 3, reps: 10 })
|
||||
const p = nextPrescription(belted, { ...cfg, bodyweight: true, repsMax: 15 })
|
||||
expect(p.kind).toBe('up')
|
||||
expect(p.weight).toBeGreaterThan(10)
|
||||
expect(p.sets).toBeUndefined()
|
||||
})
|
||||
|
||||
it('keeps climbing reps forever when no ceiling was set — the old behaviour', () => {
|
||||
const at30 = hist(LIFT, [[0, 30, 30, 30]], { sets: 3, reps: 30 })
|
||||
const p = nextPrescription(at30, cfg)
|
||||
expect(p.kind).toBe('up')
|
||||
expect(p.reps).toBe(31)
|
||||
expect(p.sets).toBeUndefined()
|
||||
})
|
||||
|
||||
it('applies to every policy, not just linear', () => {
|
||||
for (const prog of ['linear', 'greyskull', 'double']) {
|
||||
const p = nextPrescription(bw([[0, 10, 10, 4], [0, 10, 10, 4], [0, 10, 10, 4]]), { ...cfg, prog })
|
||||
@@ -390,4 +431,15 @@ describe('applyPrescription', () => {
|
||||
const timed = [{ sec: 45, w: 0, done: false }]
|
||||
expect(applyPrescription(timed, { kind: 'up', sec: 50 })).toEqual([{ sec: 50, w: 0, done: false }])
|
||||
})
|
||||
|
||||
it('grows the list when the policy added a set (issue #33)', () => {
|
||||
const three = [{ w: 0, r: 10, done: false }, { w: 0, r: 10, done: false }, { w: 0, r: 10, done: false }]
|
||||
const out = applyPrescription(three, { kind: 'up', weight: 0, reps: 10, sets: 4 })
|
||||
expect(out).toHaveLength(4)
|
||||
expect(out[3]).toEqual({ w: 0, r: 10, done: false })
|
||||
})
|
||||
|
||||
it('never shrinks a session that has already logged sets', () => {
|
||||
expect(applyPrescription(sets, { kind: 'up', weight: 60, sets: 1 })).toHaveLength(sets.length)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user