@ -17,7 +17,27 @@
@@ -17,7 +17,27 @@
var _pdf _history = require ( '../../web/pdf_history' ) ;
describe ( 'pdf_history' , function ( ) {
describe ( 'isDestsEqual' , function ( ) {
describe ( 'isDestHashesEqual' , function ( ) {
it ( 'should reject non-equal destination hashes' , function ( ) {
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( null , 'page.157' ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'title.0' , 'page.157' ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'page=1&zoom=auto' , 'page.157' ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'nameddest-page.157' , 'page.157' ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'page.157' , 'nameddest=page.157' ) ) . toEqual ( false ) ;
var destArrayString = JSON . stringify ( [ {
num : 3757 ,
gen : 0
} , { name : 'XYZ' } , 92.918 , 748.972 , null ] ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( destArrayString , 'page.157' ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'page.157' , destArrayString ) ) . toEqual ( false ) ;
} ) ;
it ( 'should accept equal destination hashes' , function ( ) {
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'page.157' , 'page.157' ) ) . toEqual ( true ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'nameddest=page.157' , 'page.157' ) ) . toEqual ( true ) ;
expect ( ( 0 , _pdf _history . isDestHashesEqual ) ( 'nameddest=page.157&zoom=100' , 'page.157' ) ) . toEqual ( true ) ;
} ) ;
} ) ;
describe ( 'isDestArraysEqual' , function ( ) {
var firstDest = [ {
num : 1 ,
gen : 0
@ -39,18 +59,18 @@ describe('pdf_history', function () {
@@ -39,18 +59,18 @@ describe('pdf_history', function () {
num : 1
} , { name : 'XYZ' } , 0 , 375 , null ] ;
it ( 'should reject non-equal destination arrays' , function ( ) {
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , undefined ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , [ 1 , 2 , 3 , 4 , 5 ] ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , secondDest ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , thirdDest ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , fourthDest ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , undefined ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , [ 1 , 2 , 3 , 4 , 5 ] ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , secondDest ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , thirdDest ) ) . toEqual ( false ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , fourthDest ) ) . toEqual ( false ) ;
} ) ;
it ( 'should accept equal destination arrays' , function ( ) {
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , firstDest ) ) . toEqual ( true ) ;
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , fifthDest ) ) . toEqual ( true ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , firstDest ) ) . toEqual ( true ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , fifthDest ) ) . toEqual ( true ) ;
var firstDestCopy = firstDest . slice ( ) ;
expect ( firstDest ) . not . toBe ( firstDestCopy ) ;
expect ( ( 0 , _pdf _history . isDestsEqual ) ( firstDest , firstDestCopy ) ) . toEqual ( true ) ;
expect ( ( 0 , _pdf _history . isDestArray sEqual ) ( firstDest , firstDestCopy ) ) . toEqual ( true ) ;
} ) ;
} ) ;
} ) ;