feat(checkin): track one-sided exercises per side (L/R)
One-sided (reps-per-side) exercises now log weight, reps, RIR/RPE and done individually per side, shown as two L/R rows per set. The per-side data rides on the set row while its scalar w/r/done/effort stay a correct aggregate, so volume, 1RM, PRs, progression, recovery, history and the coach read it unchanged. Side badges localised for all languages. Closes #60.
This commit is contained in:
1 parent
5c2005e81f
commit
af751a718e
21 files changed
+421
-28
No files matched your search
+40
-12
@@ -1,7 +1,7 @@
|
||||
// Pure helpers over the state object S (ported 1:1 from the vanilla app).
|
||||
import { todayISO, isoOf, weekKey, weekStartOf, fmtNum } from './format.js'
|
||||
import { isCardio, isBodyweightEq } from './exercises.js'
|
||||
import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, normalizeMode, extraVolumeOf, nextDropWeight, splitBurstReps } from './workout-model.js'
|
||||
import { phaseForSet, modeForSet, modeForEntry, isWarmupRow, normalizeMode, extraVolumeOf, nextDropWeight, splitBurstReps, makeSideSet, isSideSet, syncSideAggregate } from './workout-model.js'
|
||||
const objectOf = value => value && typeof value === 'object' && !Array.isArray(value) ? value : {}
|
||||
// Completed-state-independent work rows whose authoritative mode matches the requested mode.
|
||||
const workRowsForMode = (entry = {}, mode = 'reps') => {
|
||||
@@ -110,16 +110,21 @@ export function setLabel(id, s, cfg) {
|
||||
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)}` : '')
|
||||
const bw = isBw({ ...c, id: c.id ?? id })
|
||||
// One side's "weight×reps" (or bodyweight "reps" / "+belt × reps"), the same shape a whole
|
||||
// straight set reads as — reused for each side of a unilateral set below.
|
||||
const oneSide = side => {
|
||||
const reps = side.r || 0
|
||||
return bw ? (side.w > 0 ? `+${fmtNum(side.w)} × ` : '') + reps : `${fmtNum(side.w || 0)}×${reps}`
|
||||
}
|
||||
// A unilateral set logged per side (issue #60) reads "L 15×8 · R 15×7" — the asymmetry is the
|
||||
// whole point, so both sides are shown rather than a single combined total.
|
||||
if (isSideSet(s)) {
|
||||
return `${t('L')} ${oneSide(s.sides.L)}${effortTail(s.sides.L)} · ${t('R')} ${oneSide(s.sides.R)}${effortTail(s.sides.R)}`
|
||||
}
|
||||
// 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.
|
||||
// A per-side set needs no mark here: the number logged is the total, the same as every
|
||||
// other set in the app.
|
||||
const reps = 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)
|
||||
return oneSide(s) + effortTail(s)
|
||||
}
|
||||
// Default config for a freshly added exercise.
|
||||
export function defaultConfig(id, mode) {
|
||||
@@ -372,11 +377,26 @@ function buildWorkSets(S, cfg, options = {}) {
|
||||
const w = useTarget
|
||||
? (cfg.weight > 0 ? cfg.weight : (lastRegular && lastRegular.r > 0 ? lastRegular.w : cfg.weight))
|
||||
: preferLast && usable ? usable.w : (conf && conf.w > 0 ? conf.w : (usable ? usable.w : cfg.weight))
|
||||
sets.push({ w, r: usable ? usable.r : cfg.reps, done: false })
|
||||
const row = { w, r: usable ? usable.r : cfg.reps, done: false }
|
||||
// A unilateral exercise logs each side on its own (issue #60): the row splits into L/R,
|
||||
// each seeded with half the total reps at the same weight. When "last time" was itself a
|
||||
// per-side set, carry its two sides over verbatim so an asymmetry you logged persists.
|
||||
if (isPerSide(cfg)) sets.push(usable && isSideSet(usable) ? seedSideFromLast(row, usable) : makeSideSet(row))
|
||||
else sets.push(row)
|
||||
}
|
||||
return sets
|
||||
}
|
||||
|
||||
// Seed a fresh per-side row from a previous per-side set: same reps/weight each side, nothing
|
||||
// done, no effort carried (that is logged afresh each session). Falls back to an even split if
|
||||
// the previous row was not actually per-side.
|
||||
function seedSideFromLast(row, prev) {
|
||||
const base = makeSideSet(row)
|
||||
if (!isSideSet(prev)) return base
|
||||
const carry = s => ({ w: Number(s?.w) || 0, r: Number(s?.r) || 0, done: false })
|
||||
return syncSideAggregate({ ...base, sides: { L: carry(prev.sides.L), R: carry(prev.sides.R) } })
|
||||
}
|
||||
|
||||
/**
|
||||
* Stamp every work row with the exercise's planned intensifier and pre-fill its drops/clusters,
|
||||
* already computed and editable — the plan designs the set, not a button pressed mid-workout.
|
||||
@@ -430,14 +450,22 @@ export function workoutVolume(w) {
|
||||
}))
|
||||
return v
|
||||
}
|
||||
// A unilateral row counts as two toward the "x / y sets" progress — one per side — since each
|
||||
// side is logged and ticked on its own (issue #60). Every other row counts as one.
|
||||
export const setUnits = s => (isSideSet(s) ? 2 : 1)
|
||||
// How many of a row's units are done: both sides independently for a per-side row, else 0/1.
|
||||
export const doneUnits = s => (isSideSet(s) ? (s.sides.L.done ? 1 : 0) + (s.sides.R.done ? 1 : 0) : (s.done ? 1 : 0))
|
||||
// Total completion-units across a session's rows (both sides of every unilateral set counted).
|
||||
export const setUnitsTotal = entries => (entries || []).reduce((n, e) => n + (e.sets || []).reduce((m, s) => m + setUnits(s), 0), 0)
|
||||
|
||||
export function setsDone(w) {
|
||||
let n = 0
|
||||
w.entries.forEach(e => e.sets.forEach(s => { if (s.done) n++ }))
|
||||
w.entries.forEach(e => e.sets.forEach(s => { n += doneUnits(s) }))
|
||||
return n
|
||||
}
|
||||
export function setsDoneActive(A) {
|
||||
let n = 0
|
||||
if (A) A.entries.forEach(e => e.sets.forEach(s => { if (s.done) n++ }))
|
||||
if (A) A.entries.forEach(e => e.sets.forEach(s => { n += doneUnits(s) }))
|
||||
return n
|
||||
}
|
||||
export const lastBW = S => (S.bodyweight.length ? S.bodyweight[S.bodyweight.length - 1] : null)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from './history.js'
|
||||
import { nextTrainingDay, modeOf, isTimed, fmtSec, setLabel, defaultConfig, buildSets, freestyleConfig, exLine, workoutVolume, bestWeightFor, bestWeightForEntry, effortOf, stepEffort, capEffort, isBw, isPerSide, sideReps, repStep, cascadeWeight, insertWarmupRow, removeRowAt, workSetsDone, setsDone, setsDoneActive, setUnits, doneUnits, setUnitsTotal, pairAdjacent, unpairSuperset, supersetUnits, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from './history.js'
|
||||
import { makeSideSet, setSideField, toggleSide } from './workout-model.js'
|
||||
import { EXDB } from './exercises.js'
|
||||
|
||||
// Real ids out of the shipped catalogue, so the body-part fallback is exercised for real.
|
||||
@@ -1019,3 +1020,64 @@ describe('nextTrainingDay', () => {
|
||||
expect(nextTrainingDay(off, TUE)).toMatchObject({ weekday: 5 })
|
||||
})
|
||||
})
|
||||
|
||||
/* ---------- one-sided (unilateral) sets, logged per side (issue #60) ---------- */
|
||||
|
||||
// A per-side row carries its two sides and a scalar aggregate. These pin that the display shows
|
||||
// both sides, and — crucially — that every aggregate-reading consumer (volume, best weight, the
|
||||
// x/y-sets counters) treats the row correctly without knowing sides exist.
|
||||
describe('setLabel — per side', () => {
|
||||
it('shows both sides so an asymmetry is visible, not a single combined total', () => {
|
||||
const s = setSideField(setSideField(makeSideSet({ w: 15, r: 16 }), 'R', 'r', 7), 'L', 'r', 8)
|
||||
expect(setLabel(LIFT, s, { id: LIFT, side: true })).toBe('L 15×8 · R 15×7')
|
||||
})
|
||||
|
||||
it('keeps each side effort tail and reads bodyweight sides as reps alone', () => {
|
||||
let s = makeSideSet({ w: 0, r: 16 })
|
||||
s = setSideField(s, 'L', 'rir', 1)
|
||||
expect(setLabel(BW, s, { id: BW, side: true })).toBe('L 8 (RIR 1) · R 8')
|
||||
})
|
||||
})
|
||||
|
||||
describe('per-side aggregate stays readable by existing consumers', () => {
|
||||
it('workoutVolume counts both sides via the row total, unchanged from a straight set', () => {
|
||||
// 15×8 per side = 15×16 total = 240, exactly what a straight {w:15,r:16} would score.
|
||||
const side = { ...makeSideSet({ w: 15, r: 16 }), done: true }
|
||||
const synced = toggleSide(toggleSide(makeSideSet({ w: 15, r: 16 }), 'L'), 'R') // both done
|
||||
const w = { entries: [{ id: LIFT, sets: [synced] }] }
|
||||
expect(synced.done).toBe(true)
|
||||
expect(workoutVolume(w)).toBe(240)
|
||||
// and a straight equivalent scores the same
|
||||
expect(workoutVolume({ entries: [{ id: LIFT, sets: [{ w: 15, r: 16, done: true }] }] })).toBe(240)
|
||||
})
|
||||
|
||||
it('bestWeightForEntry reads the aggregate weight of a completed per-side set', () => {
|
||||
const s = toggleSide(toggleSide(setSideField(makeSideSet({ w: 15, r: 16 }), 'R', 'w', 17.5), 'L'), 'R')
|
||||
expect(bestWeightForEntry({ id: LIFT, target: { id: LIFT, side: true }, sets: [s] })).toBe(17.5)
|
||||
})
|
||||
})
|
||||
|
||||
describe('per-side set counters', () => {
|
||||
it('setUnits counts a per-side row as two, a straight row as one', () => {
|
||||
expect(setUnits(makeSideSet({ w: 15, r: 16 }))).toBe(2)
|
||||
expect(setUnits({ w: 15, r: 16 })).toBe(1)
|
||||
})
|
||||
|
||||
it('doneUnits counts each finished side independently', () => {
|
||||
const none = makeSideSet({ w: 15, r: 16 })
|
||||
expect(doneUnits(none)).toBe(0)
|
||||
expect(doneUnits(toggleSide(none, 'L'))).toBe(1)
|
||||
expect(doneUnits(toggleSide(toggleSide(none, 'L'), 'R'))).toBe(2)
|
||||
expect(doneUnits({ w: 15, r: 16, done: true })).toBe(1)
|
||||
})
|
||||
|
||||
it('setUnitsTotal / setsDoneActive account for both sides across the session', () => {
|
||||
const A = { entries: [
|
||||
{ id: LIFT, sets: [toggleSide(makeSideSet({ w: 15, r: 16 }), 'L'), makeSideSet({ w: 15, r: 16 })] }, // 2 rows × 2 sides = 4 units, 1 side done
|
||||
{ id: LIFT, sets: [{ w: 60, r: 8, done: true }] }, // 1 straight, done
|
||||
] }
|
||||
expect(setUnitsTotal(A.entries)).toBe(5)
|
||||
expect(setsDoneActive(A)).toBe(2)
|
||||
expect(setsDone({ entries: A.entries })).toBe(2)
|
||||
})
|
||||
})
|
||||
@@ -28,10 +28,10 @@ describe('Brazilian Portuguese locale', () => {
|
||||
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
|
||||
|
||||
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(626)
|
||||
expect(inherited).toHaveLength(613)
|
||||
expect(inherited).toHaveLength(615)
|
||||
// If this fails, review the changed keys and wording before accepting a new hash. From
|
||||
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
|
||||
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('81d277306b3029090b7a2ba6cc19108ca207ea65d738487155123260b6e9525d')
|
||||
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1f33b4f41974b95720a8ac936d8fc5e90ae8b705c8dcc039b2d6fe6563ec4355')
|
||||
})
|
||||
|
||||
test('does not leak European Portuguese UI terms', () => {
|
||||
|
||||
@@ -128,6 +128,85 @@ export function splitBurstReps(total) {
|
||||
return bursts
|
||||
}
|
||||
|
||||
// --- one-sided (unilateral) sets (issue #60) -------------------------------------------------
|
||||
//
|
||||
// A unilateral exercise (cfg.side, see history.js isPerSide) is trained one limb at a time, and
|
||||
// asymmetries are the whole point of tracking it — a stronger right that carries a weaker left is
|
||||
// exactly what a single combined row hides. So a per-side row logs each side on its own: weight,
|
||||
// reps, effort and its own done tick, held in `sides: { L, R }`.
|
||||
//
|
||||
// Like `drops`/`clusters`, this rides on the row while the row's own `w`/`r`/`done`/effort stay a
|
||||
// correct aggregate of the two sides — so volume, 1RM, PRs, progression, recovery, history and the
|
||||
// coach keep reading a row's scalar fields and need not know sides exist:
|
||||
// r = L.r + R.r (the both-sides total, exactly what those readers expect of a per-side set)
|
||||
// w = max(L.w, R.w) (the heavier side; the two are usually equal)
|
||||
// done = L.done && R.done (a set counts done only once both sides are)
|
||||
// effort= the harder side's rating (lower RIR / higher RPE), for the history tail only
|
||||
// `syncSideAggregate` recomputes those scalars from `sides` after any per-side edit.
|
||||
export function isSideSet(set) {
|
||||
const s = objectOf(set)
|
||||
return !!(s.sides && typeof s.sides === 'object' && s.sides.L && s.sides.R)
|
||||
}
|
||||
|
||||
const sideOf = value => {
|
||||
const v = objectOf(value)
|
||||
const out = { w: Number(v.w) || 0, r: Number(v.r) || 0, done: v.done === true }
|
||||
if (v.rir != null) out.rir = v.rir
|
||||
if (v.rpe != null) out.rpe = v.rpe
|
||||
return out
|
||||
}
|
||||
|
||||
// Build a per-side row from a plain row: each side starts as half the row's total reps (a unilateral
|
||||
// target is always even, so the split is whole) at the same weight, carrying nothing done yet.
|
||||
export function makeSideSet(row = {}) {
|
||||
const base = objectOf(row)
|
||||
const half = Math.round((Number(base.r) || 0) / 2)
|
||||
const w = Number(base.w) || 0
|
||||
const side = () => ({ w, r: half, done: false })
|
||||
const next = { ...base, sides: { L: side(), R: side() } }
|
||||
// effort/done/reps on the parent become derived — drop any straight-set leftovers so the row
|
||||
// carries one source of truth, then recompute the aggregate.
|
||||
delete next.rir; delete next.rpe
|
||||
return syncSideAggregate(next)
|
||||
}
|
||||
|
||||
// Recompute the row's scalar mirror from its two sides. No-op (returns a shallow copy) for a row
|
||||
// that is not per-side, so callers can pipe every edit through it unconditionally.
|
||||
export function syncSideAggregate(row) {
|
||||
const base = objectOf(row)
|
||||
if (!isSideSet(base)) return { ...base }
|
||||
const L = sideOf(base.sides.L)
|
||||
const R = sideOf(base.sides.R)
|
||||
const out = { ...base, sides: { L, R }, r: L.r + R.r, w: Math.max(L.w, R.w), done: L.done && R.done }
|
||||
// The row's effort tail shows the harder side: fewer reps in reserve (lower RIR) or a higher RPE.
|
||||
// Only one scale is ever in play, matching how a straight row carries rir XOR rpe.
|
||||
delete out.rir; delete out.rpe
|
||||
const rirs = [L.rir, R.rir].filter(v => v != null)
|
||||
const rpes = [L.rpe, R.rpe].filter(v => v != null)
|
||||
if (rirs.length) out.rir = Math.min(...rirs)
|
||||
else if (rpes.length) out.rpe = Math.max(...rpes)
|
||||
return out
|
||||
}
|
||||
|
||||
// Patch one field on one side ('L'|'R'), returning a new row with the aggregate resynced. A null
|
||||
// value clears an optional field (effort), mirroring how a straight row drops the key.
|
||||
export function setSideField(row, side, field, value) {
|
||||
const base = objectOf(row)
|
||||
if (!isSideSet(base) || (side !== 'L' && side !== 'R')) return { ...base }
|
||||
const cur = { ...sideOf(base.sides[side]) }
|
||||
if (value == null && (field === 'rir' || field === 'rpe')) delete cur[field]
|
||||
else cur[field] = value
|
||||
return syncSideAggregate({ ...base, sides: { ...base.sides, [side]: cur } })
|
||||
}
|
||||
|
||||
// Flip one side's done tick, resyncing the row's own done (true only when both sides are).
|
||||
export function toggleSide(row, side) {
|
||||
const base = objectOf(row)
|
||||
if (!isSideSet(base) || (side !== 'L' && side !== 'R')) return { ...base }
|
||||
const cur = { ...sideOf(base.sides[side]), done: !sideOf(base.sides[side]).done }
|
||||
return syncSideAggregate({ ...base, sides: { ...base.sides, [side]: cur } })
|
||||
}
|
||||
|
||||
export function normalizeMode(value, fallback = 'reps') {
|
||||
const token = typeof value === 'string' ? value.trim().toLowerCase() : ''
|
||||
if (MODES.includes(token)) return token
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
setType, isDropSet, isRestPauseSet, dropsOf, clustersOf, extraVolumeOf,
|
||||
addDrop, addCluster, removeDropAt, removeClusterAt, setDropAt, setClusterAt,
|
||||
nextDropWeight, nextBurstReps, splitBurstReps,
|
||||
isSideSet, makeSideSet, syncSideAggregate, setSideField, toggleSide,
|
||||
} from './workout-model.js'
|
||||
|
||||
describe('phaseForSet / isWarmupRow', () => {
|
||||
@@ -179,3 +180,100 @@ describe('modeForSet / modeForEntry stay reps-mode for drop-sets and rest-pause
|
||||
expect(modeForEntry(entry)).toBe('reps')
|
||||
})
|
||||
})
|
||||
|
||||
// One-sided (unilateral) sets: each side logged on its own, with the row's scalar w/r/done/effort
|
||||
// kept as a correct aggregate so every other consumer (volume, 1RM, PRs, progression, counters)
|
||||
// reads a per-side row exactly as it always read a straight one (issue #60).
|
||||
describe('isSideSet', () => {
|
||||
it('is true only for a row carrying both L and R sides', () => {
|
||||
expect(isSideSet({ sides: { L: { w: 10, r: 8 }, R: { w: 10, r: 8 } } })).toBe(true)
|
||||
expect(isSideSet({ w: 10, r: 8 })).toBe(false)
|
||||
expect(isSideSet({ sides: { L: { w: 10, r: 8 } } })).toBe(false)
|
||||
expect(isSideSet(null)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('makeSideSet', () => {
|
||||
it('splits the row total evenly across two sides at the same weight, nothing done', () => {
|
||||
const s = makeSideSet({ w: 15, r: 16, done: false })
|
||||
expect(isSideSet(s)).toBe(true)
|
||||
expect(s.sides.L).toEqual({ w: 15, r: 8, done: false })
|
||||
expect(s.sides.R).toEqual({ w: 15, r: 8, done: false })
|
||||
// aggregate mirror: r = both sides, w = the (equal) weight, not done yet
|
||||
expect(s.r).toBe(16)
|
||||
expect(s.w).toBe(15)
|
||||
expect(s.done).toBe(false)
|
||||
})
|
||||
|
||||
it('drops any straight-set effort so the row carries a single source of truth', () => {
|
||||
const s = makeSideSet({ w: 20, r: 10, rir: 2 })
|
||||
expect(s.rir).toBeUndefined()
|
||||
expect(s.rpe).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('syncSideAggregate', () => {
|
||||
it('recomputes r as the sum, w as the heavier side, done only when both sides are', () => {
|
||||
const row = { sides: { L: { w: 15, r: 8, done: true }, R: { w: 17.5, r: 6, done: false } } }
|
||||
const s = syncSideAggregate(row)
|
||||
expect(s.r).toBe(14)
|
||||
expect(s.w).toBe(17.5)
|
||||
expect(s.done).toBe(false)
|
||||
const bothDone = syncSideAggregate({ sides: { L: { w: 15, r: 8, done: true }, R: { w: 15, r: 8, done: true } } })
|
||||
expect(bothDone.done).toBe(true)
|
||||
})
|
||||
|
||||
it('takes the harder side for the row effort — lower RIR, higher RPE', () => {
|
||||
const rir = syncSideAggregate({ sides: { L: { w: 15, r: 8, rir: 3 }, R: { w: 15, r: 8, rir: 1 } } })
|
||||
expect(rir.rir).toBe(1)
|
||||
expect(rir.rpe).toBeUndefined()
|
||||
const rpe = syncSideAggregate({ sides: { L: { w: 15, r: 8, rpe: 7 }, R: { w: 15, r: 8, rpe: 9 } } })
|
||||
expect(rpe.rpe).toBe(9)
|
||||
expect(rpe.rir).toBeUndefined()
|
||||
})
|
||||
|
||||
it('leaves a non-per-side row alone (returns a copy)', () => {
|
||||
const s = syncSideAggregate({ w: 20, r: 10, done: true })
|
||||
expect(s).toEqual({ w: 20, r: 10, done: true })
|
||||
expect(isSideSet(s)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('setSideField', () => {
|
||||
it('patches one side and resyncs the aggregate', () => {
|
||||
const base = makeSideSet({ w: 15, r: 16 })
|
||||
const s = setSideField(base, 'R', 'w', 17.5)
|
||||
expect(s.sides.R.w).toBe(17.5)
|
||||
expect(s.sides.L.w).toBe(15)
|
||||
expect(s.w).toBe(17.5) // aggregate = heavier side
|
||||
})
|
||||
|
||||
it('clears an effort field on null, mirroring how a straight row drops the key', () => {
|
||||
let s = setSideField(makeSideSet({ w: 15, r: 16 }), 'L', 'rir', 2)
|
||||
expect(s.sides.L.rir).toBe(2)
|
||||
expect(s.rir).toBe(2)
|
||||
s = setSideField(s, 'L', 'rir', null)
|
||||
expect(s.sides.L.rir).toBeUndefined()
|
||||
expect(s.rir).toBeUndefined()
|
||||
})
|
||||
|
||||
it('ignores an unknown side without throwing', () => {
|
||||
const base = makeSideSet({ w: 15, r: 16 })
|
||||
expect(isSideSet(setSideField(base, 'X', 'w', 20))).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('toggleSide', () => {
|
||||
it('flips one side and marks the row done only once both sides are', () => {
|
||||
let s = makeSideSet({ w: 15, r: 16 })
|
||||
expect(s.done).toBe(false)
|
||||
s = toggleSide(s, 'L')
|
||||
expect(s.sides.L.done).toBe(true)
|
||||
expect(s.done).toBe(false) // R still open
|
||||
s = toggleSide(s, 'R')
|
||||
expect(s.sides.R.done).toBe(true)
|
||||
expect(s.done).toBe(true) // both sides done → row done
|
||||
s = toggleSide(s, 'L')
|
||||
expect(s.done).toBe(false) // un-tick one side → row no longer done
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user