|
1 | 1 | import request from 'supertest'; |
2 | 2 |
|
| 3 | +import { routes } from '@/routes'; |
| 4 | + |
3 | 5 | const port = 5557; |
4 | 6 | const origin = 'http://localhost:3000'; |
5 | 7 |
|
@@ -36,4 +38,34 @@ describe('Server Tests', () => { |
36 | 38 | expect(response.body.error).toBe('Forbidden'); |
37 | 39 | }); |
38 | 40 | }); |
| 41 | + |
| 42 | + it('should allow JSON payloads up to 500kb for the CONVERT_MARKDOWN route', async () => { |
| 43 | + const largePayload = 'a'.repeat(400 * 1024); // 400kb payload |
| 44 | + const response = await request(app) |
| 45 | + .post(routes.CONVERT_MARKDOWN) |
| 46 | + .send({ data: largePayload }) |
| 47 | + .set('Content-Type', 'application/json'); |
| 48 | + |
| 49 | + expect(response.status).not.toBe(413); |
| 50 | + }); |
| 51 | + |
| 52 | + it('should reject JSON payloads larger than 500kb for the CONVERT_MARKDOWN route', async () => { |
| 53 | + const oversizedPayload = 'a'.repeat(501 * 1024); // 501kb payload |
| 54 | + const response = await request(app) |
| 55 | + .post(routes.CONVERT_MARKDOWN) |
| 56 | + .send({ data: oversizedPayload }) |
| 57 | + .set('Content-Type', 'application/json'); |
| 58 | + |
| 59 | + expect(response.status).toBe(413); |
| 60 | + }); |
| 61 | + |
| 62 | + it('should use the default JSON limit for other routes', async () => { |
| 63 | + const largePayload = 'a'.repeat(150 * 1024); |
| 64 | + const response = await request(app) |
| 65 | + .post('/some-other-route') |
| 66 | + .send({ data: largePayload }) |
| 67 | + .set('Content-Type', 'application/json'); |
| 68 | + |
| 69 | + expect(response.status).toBe(413); |
| 70 | + }); |
39 | 71 | }); |
0 commit comments