From f31729fef1c20246f59e29651c76301802ac7641 Mon Sep 17 00:00:00 2001 From: Errr0rr404 <37506695+Errr0rr404@users.noreply.github.com> Date: Thu, 23 Jul 2026 12:31:48 -0400 Subject: [PATCH] test(req): cover req.is() when given an array of types The array branch in lib/request.js was the only uncovered branch in that file. Adds tests matching the documented String|Array API. Fixes #7348 --- test/req.is.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/req.is.js b/test/req.is.js index c5904dd600a..c8326439cfa 100644 --- a/test/req.is.js +++ b/test/req.is.js @@ -166,4 +166,48 @@ describe('req.is()', function () { .expect(200, '"application/json"', done) }) }) + + describe('when given an array', function () { + it('should return the type when matching', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is(['html', 'json'])) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, '"json"', done) + }) + + it('should return false when not matching', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is(['html', 'image/png'])) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, 'false', done) + }) + + it('should support mime types in the array', function (done) { + var app = express() + + app.use(function (req, res) { + res.json(req.is(['text/html', 'application/json'])) + }) + + request(app) + .post('/') + .type('application/json') + .send('{}') + .expect(200, '"application/json"', done) + }) + }) })