From 05ba97b2b7c0b15d31b42fdd14094eab015c9c90 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Thu, 25 Aug 2016 12:38:05 +0300 Subject: [PATCH] [node][tests] Add a test for making sure the map object throws on invalid style Currently this error is not reported. --- platform/node/test/js/map.test.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index e8434bc77..6ffbf3eb6 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -104,6 +104,21 @@ test('Map', function(t) { t.end(); }); + t.test('requires a map style to be a valid style JSON', function(t) { + var map = new mbgl.Map(options); + + t.throws(function() { + map.load('foo bar'); + }, /Requires a map style to be a valid style JSON/); + + t.throws(function() { + map.load('""'); + }, /Requires a map style to be a valid style JSON/); + + map.release(); + t.end(); + }); + t.test('expect either an object or array at root', { timeout: 1000 }, function(t) { var map = new mbgl.Map(options); @@ -116,7 +131,9 @@ test('Map', function(t) { t.end(); }); - map.load('invalid'); + t.throws(function() { + map.load('invalid'); + }, /Requires a map style to be a valid style JSON/); }); t.test('accepts an empty stylesheet string', function(t) {