feat(compare): academics strips with England anchors and More measures

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0146VHeLAWjDVE2B5uU67jCB
This commit is contained in:
Tudor
2026-07-13 23:50:29 +01:00
co-authored by Claude Fable 5
parent 9f2260ce50
commit 2573cd2490
3 changed files with 338 additions and 0 deletions
@@ -229,3 +229,31 @@ describe('stripPositions', () => {
expect(pts[0].pos).toBe(0);
});
});
describe('latestValues', () => {
const data = {
'1': {
yearly_data: [
{ year: 202324, rwm_expected_pct: 75 },
{ year: 202425, rwm_expected_pct: 87 },
],
},
'2': {
yearly_data: [
{ year: 202324, rwm_expected_pct: 82 },
{ year: 202425, rwm_expected_pct: null },
],
},
};
it('takes the latest non-null value per school in urn order', async () => {
const { latestValues } = await import('@/lib/compareLogic');
expect(latestValues(data, [1, 2], 'rwm_expected_pct')).toEqual([87, 82]);
});
it('returns null for unknown schools and metrics', async () => {
const { latestValues } = await import('@/lib/compareLogic');
expect(latestValues(data, [3], 'rwm_expected_pct')).toEqual([null]);
expect(latestValues(data, [1], 'nope')).toEqual([null]);
});
});