mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +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
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