mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Fixes unit tests and adds few for util.js
This commit is contained in:
parent
00f1d6dbf1
commit
0dd445bf18
4 changed files with 62 additions and 5 deletions
|
@ -6,7 +6,7 @@
|
|||
describe('api', function() {
|
||||
// TODO run with worker enabled
|
||||
PDFJS.disableWorker = true;
|
||||
var basicApiUrl = '../pdfs/basicapi.pdf';
|
||||
var basicApiUrl = combineUrl(window.location.href, '../pdfs/basicapi.pdf');
|
||||
function waitsForPromise(promise) {
|
||||
waitsFor(function() {
|
||||
return promise.isResolved || promise.isRejected;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
<script type="text/javascript" src="stream_spec.js"></script>
|
||||
<script type="text/javascript" src="api_spec.js"></script>
|
||||
<script type="text/javascript" src="metadata_spec.js"></script>
|
||||
<script type="text/javascript" src="util_spec.js"></script>
|
||||
<script type="text/javascript">
|
||||
'use strict';
|
||||
|
||||
|
|
51
test/unit/util_spec.js
Normal file
51
test/unit/util_spec.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('util', function() {
|
||||
|
||||
describe('combineUrl', function() {
|
||||
it('absolute url with protocol stays as is', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = 'http://server2/test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server2/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('absolute url without protocol uses prefix from base', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = '/test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url with base', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url (w/hash) with base', function() {
|
||||
var baseUrl = 'http://server/index.html#!/test';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url (w/query) with base', function() {
|
||||
var baseUrl = 'http://server/index.html?search=/test';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue