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:
@@ -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]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user