[ui/vis_maps/tests] add failing test

This commit is contained in:
spalger 2017-01-05 13:21:20 -07:00
parent 084b914a1e
commit f38e7dc428

View file

@ -2,12 +2,6 @@ import expect from 'expect.js';
import ngMock from 'ng_mock';
import url from 'url';
function matchUrlWithoutQuery(expected) {
return (url) => (
expected === url.split('?')[0]
);
}
describe('tilemaptest - TileMapSettingsTests-mocked', function () {
let tilemapSettings;
let tilemapsConfig;
@ -34,41 +28,42 @@ describe('tilemaptest - TileMapSettingsTests-mocked', function () {
tilemapSettings = $injector.get('tilemapSettings');
tilemapsConfig = $injector.get('tilemapsConfig');
// body and headers copied from https://proxy-tiles.elastic.co/v1/manifest
const MANIFEST_BODY = `{
"version":"0.0.0",
"expiry":"14d",
"services":[
{
"id":"road_map",
"url":"https://proxy-tiles.elastic.co/v1/default/{z}/{x}/{y}.png",
"minZoom":0,
"maxZoom":12,
"attribution":"© [Elastic Tile Service](https://www.elastic.co/elastic-tile-service)",
"query_parameters":{
"elastic_tile_service_tos":"agree",
"my_app_name":"kibana"
loadSettings = (expectedUrl) => {
// body and headers copied from https://proxy-tiles.elastic.co/v1/manifest
const MANIFEST_BODY = `{
"version":"0.0.0",
"expiry":"14d",
"services":[
{
"id":"road_map",
"url":"https://proxy-tiles.elastic.co/v1/default/{z}/{x}/{y}.png",
"minZoom":0,
"maxZoom":12,
"attribution":"© [Elastic Tile Service](https://www.elastic.co/elastic-tile-service)",
"query_parameters":{
"elastic_tile_service_tos":"agree",
"my_app_name":"kibana"
}
}
}
]
}`;
]
}`;
const MANIFEST_HEADERS = {
'access-control-allow-methods': 'GET, OPTIONS',
'access-control-allow-origin': '*',
'content-length': `${MANIFEST_BODY.length}`,
'content-type': 'application/json; charset=utf-8',
date: (new Date()).toUTCString(),
server: 'tileprox/20170102101655-a02e54d',
status: '200',
};
const MANIFEST_HEADERS = {
'access-control-allow-methods': 'GET, OPTIONS',
'access-control-allow-origin': '*',
'content-length': `${MANIFEST_BODY.length}`,
'content-type': 'application/json; charset=utf-8',
date: (new Date()).toUTCString(),
server: 'tileprox/20170102101655-a02e54d',
status: '200',
};
$httpBackend
.expect('GET', matchUrlWithoutQuery('http://foo.bar/manifest'))
.respond(MANIFEST_BODY, MANIFEST_HEADERS);
$httpBackend
.expect('GET', expectedUrl ? expectedUrl : () => true)
.respond(MANIFEST_BODY, MANIFEST_HEADERS);
loadSettings = () => {
tilemapSettings.loadSettings();
$httpBackend.flush();
};
}));
@ -139,6 +134,12 @@ describe('tilemaptest - TileMapSettingsTests-mocked', function () {
assertQuery({ foo: 'tstool', bar: 'stool' });
});
it('merges query params into manifest request', () => {
tilemapSettings.addQueryParams({ foo: 'bar' });
tilemapsConfig.manifestServiceUrl = 'http://test.com/manifest?v=1';
loadSettings('http://test.com/manifest?v=1&foo=bar');
});
});
});