From e9bc0732c0aea7d687864c8c1608497c387dd201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 19 Jul 2017 12:33:57 +0200 Subject: [PATCH] Use switch statement instead of if ... else if ... else ... --- test/support/test-client.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/test/support/test-client.js b/test/support/test-client.js index 48ef0eb5..9d1d1d7e 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -575,15 +575,22 @@ TestClient.prototype.getTile = function(z, x, y, params, callback) { assert.response(self.server, request, expectedResponse, function(res, err) { assert.ifError(err); - var body; - if (res.headers['content-type'] === 'image/png') { - body = mapnik.Image.fromBytes(new Buffer(res.body, 'binary')); - } else if (res.headers['content-type'] === 'application/x-protobuf') { - body = new mapnik.VectorTile(z, x, y); - body.setDataSync(new Buffer(res.body, 'binary')); - } else if (res.headers['content-type'] === 'application/json; charset=utf-8') { - body = JSON.parse(res.body); + var body; + switch (res.headers['content-type']) { + case 'image/png': + body = mapnik.Image.fromBytes(new Buffer(res.body, 'binary')); + break; + case 'application/x-protobuf': + body = new mapnik.VectorTile(z, x, y); + body.setDataSync(new Buffer(res.body, 'binary')); + break; + case 'application/json; charset=utf-8': + body = JSON.parse(res.body); + break; + default: + body = res.body + break; } next(null, res, body);