// Session 50 — POST /api/parlay/grade (the Parlay Lab endpoint). const request = require('supertest'); const app = require('../../src/app'); const legs = (n) => Array.from({ length: n }, (_, i) => ({ player: `P${i}`, team: i % 2 ? 'BOS' : 'NYY', game: 'NYY@BOS', stat: 'hits', line: 1.5, grade: i % 2 ? 'B+' : 'A' })); describe('POST /api/parlay/grade', () => { it('returns combined grade + correlation + payout for a valid parlay', async () => { const res = await request(app).post('/api/parlay/grade').send({ legs: legs(3), betAmount: 10 }); expect(res.status).toBe(200); expect(res.body.combined.grade).toBeTruthy(); expect(typeof res.body.correlation.avg).toBe('number'); expect(res.body.payout.amount).toBeGreaterThan(0); expect(res.body.legs).toHaveLength(3); }); it('handles 2 and 6 legs', async () => { expect((await request(app).post('/api/parlay/grade').send({ legs: legs(2) })).status).toBe(200); expect((await request(app).post('/api/parlay/grade').send({ legs: legs(6) })).status).toBe(200); }); it('rejects < 2 or > 6 legs (400)', async () => { expect((await request(app).post('/api/parlay/grade').send({ legs: legs(1) })).status).toBe(400); expect((await request(app).post('/api/parlay/grade').send({ legs: legs(7) })).status).toBe(400); }); });