1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #9975 from Snuffleupagus/getDestination-refactor

Re-factor `destinations`/`getDestination` to reduce unnecessary duplication, and reject non-string inputs
This commit is contained in:
Tim van der Meij 2018-08-12 15:51:58 +02:00 committed by GitHub
commit 1268aea2b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 50 deletions

View file

@ -583,6 +583,32 @@ describe('api', function() {
});
});
it('gets non-string destination', function(done) {
let numberPromise = doc.getDestination(4.3);
let booleanPromise = doc.getDestination(true);
let arrayPromise = doc.getDestination([
{ num: 17, gen: 0, }, { name: 'XYZ', }, 0, 841.89, null]);
numberPromise = numberPromise.then(function() {
throw new Error('shall fail for non-string destination.');
}, function(reason) {
expect(reason instanceof Error).toEqual(true);
});
booleanPromise = booleanPromise.then(function() {
throw new Error('shall fail for non-string destination.');
}, function(reason) {
expect(reason instanceof Error).toEqual(true);
});
arrayPromise = arrayPromise.then(function() {
throw new Error('shall fail for non-string destination.');
}, function(reason) {
expect(reason instanceof Error).toEqual(true);
});
Promise.all([numberPromise, booleanPromise, arrayPromise]).then(
done, done.fail);
});
it('gets non-existent page labels', function (done) {
var promise = doc.getPageLabels();
promise.then(function (data) {