diff --git a/test/acceptance/ported/attributes.js b/test/acceptance/ported/attributes.js index da6bfcba..ddccb814 100644 --- a/test/acceptance/ported/attributes.js +++ b/test/acceptance/ported/attributes.js @@ -235,7 +235,10 @@ describe('attributes', function() { assert.ifError(err); // jsonp errors should be returned with HTTP status 200 assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body); - assert.equal(res.body, 'test({"errors":["Layer 0 has no exposed attributes"]});'); + assert.equal( + res.body, + '/**/ typeof test === \'function\' && test({"errors":["Layer 0 has no exposed attributes"]});' + ); return null; }, function do_get_attr_1(err) diff --git a/test/acceptance/ported/multilayer_error_cases.js b/test/acceptance/ported/multilayer_error_cases.js index 9d2f55f5..2434900d 100644 --- a/test/acceptance/ported/multilayer_error_cases.js +++ b/test/acceptance/ported/multilayer_error_cases.js @@ -56,7 +56,10 @@ describe('multilayer error cases', function() { headers: {'Content-Type': 'application/json' } }, {}, function(res) { assert.equal(res.statusCode, 200); - assert.equal(res.body, 'test({"errors":["Missing layers array from layergroup config"]});'); + assert.equal( + res.body, + '/**/ typeof test === \'function\' && test({"errors":["Missing layers array from layergroup config"]});' + ); done(); }); }); @@ -340,7 +343,10 @@ describe('multilayer error cases', function() { } }; testClient.createLayergroup(bogusSqlMapConfig, options, function(err, res) { - assert.ok(/^test\(/.test(res.body), "Body start expected callback name: " + res.body); + assert.ok( + /^\/\*\*\/ typeof test === 'function' && test\(/.test(res.body), + "Body start expected callback name: " + res.body + ); assert.ok(/syntax error/.test(res.body), "Unexpected error: " + res.body); done(); }); @@ -356,7 +362,10 @@ describe('multilayer error cases', function() { } }; testClient.createLayergroup(noGeomMapConfig, options, function(err, res) { - assert.ok(/^test\(/.test(res.body), "Body start expected callback name: " + res.body); + assert.ok( + /^\/\*\*\/ typeof test === 'function' && test\(/.test(res.body), + "Body start expected callback name: " + res.body + ); assert.ok(/column.*does not exist/.test(res.body), "Unexpected error: " + res.body); done(); }); diff --git a/test/acceptance/ported/server.js b/test/acceptance/ported/server.js index 207f591a..e66998f3 100644 --- a/test/acceptance/ported/server.js +++ b/test/acceptance/ported/server.js @@ -111,13 +111,20 @@ describe('server', function() { it("grid jsonp", function(done){ var mapConfig = testClient.singleLayerMapConfig('select * from test_table', null, null, 'name'); - testClient.getGridJsonp(mapConfig, 0, 13, 4011, 3088, 'test', function(err, res) { + testClient.getGridJsonp(mapConfig, 0, 13, 4011, 3088, 'jsonp_test', function(err, res) { assert.equal(res.statusCode, 200, res.body); - assert.deepEqual(res.headers['content-type'], 'application/json; charset=utf-8'); - var regexp = '^test\\((.*)\\);$'; - var matches = res.body.match(regexp); - assert.equal(matches.length, 2, 'Unexpected JSONP response:' + res.body); - assert.utfgridEqualsFile(matches[1], './test/fixtures/test_table_13_4011_3088.grid.json', 2, done); + assert.deepEqual(res.headers['content-type'], 'text/javascript; charset=utf-8'); + var didRunJsonCallback = false; + var response = {}; + // jshint ignore:start + function jsonp_test(body) { + response = body; + didRunJsonCallback = true; + } + eval(res.body); + // jshint ignore:end + assert.ok(didRunJsonCallback); + assert.utfgridEqualsFile(response, './test/fixtures/test_table_13_4011_3088.grid.json', 2, done); }); }); @@ -145,7 +152,7 @@ describe('server', function() { } }; testClient.getGrid(mapConfig, 0, 13, 4011, 3088, expectedResponse, function(err, res) { - console.log(res.body); + assert.deepEqual(JSON.parse(res.body), {"errors":["Tileset has no interactivity"]}); done(); }); }); diff --git a/test/acceptance/ported/support/test_client.js b/test/acceptance/ported/support/test_client.js index 9ad4f6ce..8544aced 100644 --- a/test/acceptance/ported/support/test_client.js +++ b/test/acceptance/ported/support/test_client.js @@ -44,6 +44,7 @@ server.setMaxListeners(0); var redisClient = redis.createClient(global.environment.redis.port); var jsonContentType = 'application/json; charset=utf-8'; +var jsContentType = 'text/javascript; charset=utf-8'; var pngContentType = 'image/png'; function createLayergroup(layergroupConfig, options, callback) { @@ -218,7 +219,7 @@ function getGrid(layergroupConfig, layer, z, x, y, expectedResponse, callback) { function getGridJsonp(layergroupConfig, layer, z, x, y, jsonpCallbackName, expectedResponse, callback) { if (!callback) { callback = expectedResponse; - expectedResponse = jsonContentType; + expectedResponse = jsContentType; } var options = {