@ -58,20 +58,19 @@ describe('api', function () {
@@ -58,20 +58,19 @@ describe('api', function () {
expect ( data [ 0 ] . loaded / data [ 0 ] . total > 0 ) . toEqual ( true ) ;
expect ( data [ 1 ] instanceof _api . PDFDocumentProxy ) . toEqual ( true ) ;
expect ( loadingTask ) . toEqual ( data [ 1 ] . loadingTask ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
} ) ;
it ( 'creates pdf doc from URL and aborts before worker initialized' , function ( done ) {
var loadingTask = _global . PDFJS . getDocument ( basicApiUrl ) ;
loadingTask . destroy ( ) ;
var destroyed = loadingTask . destroy ( ) ;
loadingTask . promise . then ( function ( reason ) {
done . fail ( 'shall fail loading' ) ;
} ) . catch ( function ( reason ) {
expect ( true ) . toEqual ( true ) ;
don e ( ) ;
destr oyed . th en ( done ) ;
} ) ;
} ) ;
it ( 'creates pdf doc from URL and aborts loading after worker initialized' , function ( done ) {
@ -115,8 +114,7 @@ describe('api', function () {
@@ -115,8 +114,7 @@ describe('api', function () {
var loadingTask = _global . PDFJS . getDocument ( typedArrayPdf ) ;
loadingTask . promise . then ( function ( data ) {
expect ( data instanceof _api . PDFDocumentProxy ) . toEqual ( true ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -128,8 +126,7 @@ describe('api', function () {
@@ -128,8 +126,7 @@ describe('api', function () {
done . fail ( 'shall fail loading' ) ;
} ) . catch ( function ( error ) {
expect ( error instanceof _util . InvalidPDFException ) . toEqual ( true ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) ;
} ) ;
it ( 'creates pdf doc from non-existent URL' , function ( done ) {
@ -139,8 +136,7 @@ describe('api', function () {
@@ -139,8 +136,7 @@ describe('api', function () {
done . fail ( 'shall fail loading' ) ;
} ) . catch ( function ( error ) {
expect ( error instanceof _util . MissingPDFException ) . toEqual ( true ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) ;
} ) ;
it ( 'creates pdf doc from PDF file protected with user and owner password' , function ( done ) {
@ -168,8 +164,7 @@ describe('api', function () {
@@ -168,8 +164,7 @@ describe('api', function () {
var promises = [ passwordNeededCapability . promise , passwordIncorrectCapability . promise , loadingTask . promise ] ;
Promise . all ( promises ) . then ( function ( data ) {
expect ( data [ 2 ] instanceof _api . PDFDocumentProxy ) . toEqual ( true ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -221,9 +216,10 @@ describe('api', function () {
@@ -221,9 +216,10 @@ describe('api', function () {
url : url ,
password : 'qwerty'
} ) ;
var passwordNeededDestroyed = void 0 ;
passwordNeededLoadingTask . onPassword = function ( callback , reason ) {
if ( reason === _util . PasswordResponses . NEED _PASSWORD ) {
passwordNeededLoadingTask . destroy ( ) ;
passwordNeededDestroyed = passwordNeeded LoadingTask . destroy ( ) ;
return ;
}
expect ( false ) . toEqual ( true ) ;
@ -234,6 +230,7 @@ describe('api', function () {
@@ -234,6 +230,7 @@ describe('api', function () {
} , function ( reason ) {
expect ( reason instanceof _util . PasswordException ) . toEqual ( true ) ;
expect ( reason . code ) . toEqual ( _util . PasswordResponses . NEED _PASSWORD ) ;
return passwordNeededDestroyed ;
} ) ;
passwordIncorrectLoadingTask . onPassword = function ( callback , reason ) {
if ( reason === _util . PasswordResponses . INCORRECT _PASSWORD ) {
@ -342,8 +339,8 @@ describe('api', function () {
@@ -342,8 +339,8 @@ describe('api', function () {
done ( ) ;
} ) ;
} ) ;
afterAll ( function ( ) {
loadingTask . destroy ( ) ;
afterAll ( function ( done ) {
loadingTask . destroy ( ) . then ( done ) ;
} ) ;
it ( 'gets number of pages' , function ( ) {
expect ( doc . numPages ) . toEqual ( 3 ) ;
@ -466,8 +463,7 @@ describe('api', function () {
@@ -466,8 +463,7 @@ describe('api', function () {
gen : 0
} , { name : 'XYZ' } , 0 , 375 , null ]
} ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -483,8 +479,7 @@ describe('api', function () {
@@ -483,8 +479,7 @@ describe('api', function () {
num : 1 ,
gen : 0
} , { name : 'XYZ' } , 0 , 375 , null ] ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -497,8 +492,7 @@ describe('api', function () {
@@ -497,8 +492,7 @@ describe('api', function () {
} ) ;
promise . then ( function ( destination ) {
expect ( destination ) . toEqual ( null ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -538,11 +532,7 @@ describe('api', function () {
@@ -538,11 +532,7 @@ describe('api', function () {
expect ( pageLabels [ 1 ] ) . toEqual ( [ 'Front Page1' ] ) ;
expect ( pageLabels [ 2 ] ) . toEqual ( [ '1' , '2' ] ) ;
expect ( pageLabels [ 3 ] ) . toEqual ( [ 'X3' ] ) ;
loadingTask0 . destroy ( ) ;
loadingTask1 . destroy ( ) ;
loadingTask2 . destroy ( ) ;
loadingTask3 . destroy ( ) ;
done ( ) ;
Promise . all ( [ loadingTask0 . destroy ( ) , loadingTask1 . destroy ( ) , loadingTask2 . destroy ( ) , loadingTask3 . destroy ( ) ] ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -567,8 +557,7 @@ describe('api', function () {
@@ -567,8 +557,7 @@ describe('api', function () {
expect ( attachment . filename ) . toEqual ( 'Press Quality.joboptions' ) ;
expect ( attachment . content instanceof Uint8Array ) . toBeTruthy ( ) ;
expect ( attachment . content . length ) . toEqual ( 30098 ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -592,8 +581,7 @@ describe('api', function () {
@@ -592,8 +581,7 @@ describe('api', function () {
promise . then ( function ( data ) {
expect ( data ) . toEqual ( [ 'print({});' ] ) ;
expect ( data [ 0 ] ) . toMatch ( viewerPrintRegExp ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -607,8 +595,7 @@ describe('api', function () {
@@ -607,8 +595,7 @@ describe('api', function () {
promise . then ( function ( data ) {
expect ( data ) . toEqual ( [ 'this.print({bUI:true,bSilent:false,bShrinkToFit:true});' ] ) ;
expect ( data [ 0 ] ) . toMatch ( viewerPrintRegExp ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -621,8 +608,7 @@ describe('api', function () {
@@ -621,8 +608,7 @@ describe('api', function () {
} ) ;
promise . then ( function ( outline ) {
expect ( outline ) . toEqual ( null ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -665,8 +651,7 @@ describe('api', function () {
@@ -665,8 +651,7 @@ describe('api', function () {
expect ( outlineItemOne . bold ) . toEqual ( false ) ;
expect ( outlineItemOne . italic ) . toEqual ( true ) ;
expect ( outlineItemOne . color ) . toEqual ( new Uint8Array ( [ 0 , 0 , 0 ] ) ) ;
loadingTask . destroy ( ) ;
done ( ) ;
loadingTask . destroy ( ) . then ( done ) ;
} ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
@ -728,9 +713,7 @@ describe('api', function () {
@@ -728,9 +713,7 @@ describe('api', function () {
expect ( typeof fingerprint2 === 'undefined' ? 'undefined' : _typeof ( fingerprint2 ) ) . toEqual ( 'string' ) ;
expect ( fingerprint2 . length > 0 ) . toEqual ( true ) ;
expect ( fingerprint1 ) . not . toEqual ( fingerprint2 ) ;
loadingTask1 . destroy ( ) ;
loadingTask2 . destroy ( ) ;
done ( ) ;
Promise . all ( [ loadingTask1 . destroy ( ) , loadingTask2 . destroy ( ) ] ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;
@ -751,8 +734,8 @@ describe('api', function () {
@@ -751,8 +734,8 @@ describe('api', function () {
done . fail ( reason ) ;
} ) ;
} ) ;
afterAll ( function ( ) {
loadingTask . destroy ( ) ;
afterAll ( function ( done ) {
loadingTask . destroy ( ) . then ( done ) ;
} ) ;
it ( 'gets page number' , function ( ) {
expect ( page . pageNumber ) . toEqual ( 1 ) ;
@ -833,10 +816,7 @@ describe('api', function () {
@@ -833,10 +816,7 @@ describe('api', function () {
expect ( docBaseUrlAnnotations [ 0 ] . unsafeUrl ) . toEqual ( '../../0021/002156/215675E.pdf#nameddest=15' ) ;
expect ( invalidDocBaseUrlAnnotations [ 0 ] . url ) . toBeUndefined ( ) ;
expect ( invalidDocBaseUrlAnnotations [ 0 ] . unsafeUrl ) . toEqual ( '../../0021/002156/215675E.pdf#nameddest=15' ) ;
defaultLoadingTask . destroy ( ) ;
docBaseUrlLoadingTask . destroy ( ) ;
invalidDocBaseUrlLoadingTask . destroy ( ) ;
done ( ) ;
Promise . all ( [ defaultLoadingTask . destroy ( ) , docBaseUrlLoadingTask . destroy ( ) , invalidDocBaseUrlLoadingTask . destroy ( ) ] ) . then ( done ) ;
} ) . catch ( function ( reason ) {
done . fail ( reason ) ;
} ) ;