openseadragon/test/modules/dzitilesource.js

51 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2017-12-07 04:20:39 +03:00
/* global QUnit, testLog */
(function() {
2017-12-07 04:20:39 +03:00
QUnit.module('DziTileSource', {
beforeEach: function() {
testLog.reset();
}
});
2017-12-07 04:20:39 +03:00
function testImplicitTilesUrl(assert, dziUrl, expected, msg) {
var source = new OpenSeadragon.DziTileSource();
var options = source.configure({
Image: {Size: {Width:0, Height: 0}}
}, dziUrl);
2017-12-07 04:20:39 +03:00
assert.equal(options.tilesUrl, expected, msg);
}
2017-12-07 04:20:39 +03:00
QUnit.test('test implicit tilesUrl guessed from dzi url', function(assert) {
testImplicitTilesUrl(
2017-12-07 04:20:39 +03:00
assert,
'/path/my.dzi', '/path/my_files/',
'dzi extension should be stripped');
testImplicitTilesUrl(
2017-12-07 04:20:39 +03:00
assert,
'/path/my', '/path/my_files/',
'no extension should still produce _files path');
testImplicitTilesUrl(
2017-12-07 04:20:39 +03:00
assert,
'/my/', '/my_files/',
'no extension with trailing slash should preserve slash');
testImplicitTilesUrl(
2017-12-07 04:20:39 +03:00
assert,
'my.xml', 'my_files/',
'relative link should stay the same');
testImplicitTilesUrl(
2017-12-07 04:20:39 +03:00
assert,
'/p/foo.dzi?a=1&b=2', '/p/foo_files/',
'querystring in dzi url should be ignored after slashes');
testImplicitTilesUrl(
2017-12-07 04:20:39 +03:00
assert,
2016-11-08 02:02:59 +03:00
'/iiipsrv?DeepZoom=/path/my.dzi', '/iiipsrv?DeepZoom=/path/my_files/',
'querystring in dzi url should not be ignored before slashes');
testImplicitTilesUrl(
2017-12-07 04:20:39 +03:00
assert,
'/fcg-bin/iipsrv.fcgi?Deepzoom=123test.tif.dzi', '/fcg-bin/iipsrv.fcgi?Deepzoom=123test.tif_files/',
'filename in querystring does not have to contain slash');
});
}());