support maximum request body size
[squeep-api-dingus] / test / lib / dingus.js
index 519feb0bb27e0ee30fb8d9b50999d21761d60b88..23b7e8c4a834fad503664b0c9bb0d3ab00bee7e4 100644 (file)
@@ -514,6 +514,17 @@ describe('Dingus', function () {
         assert.strictEqual(e, 'foo');
       }
     });
+    it('limits size', async function () {
+      const p = dingus.bodyData(res, 8);
+      resEvents['data'](Buffer.from('foobar'));
+      resEvents['data'](Buffer.from('bazquux'));
+      try {
+        await p;
+        assert.fail(noExpectedException);
+      } catch (e) {
+        assert.strictEqual(e.statusCode, 413);
+      }
+    });
   }); // bodyData
 
   describe('ingestBody', function () {