File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -441,7 +441,14 @@ function isCmd(v, cmd) {
441
441
}
442
442
443
443
function isDict (v , type ) {
444
- return v instanceof Dict && (!type || v .get ('Type' ).name == type );
444
+ if (!(v instanceof Dict )) {
445
+ return false ;
446
+ }
447
+ if (!type ) {
448
+ return true ;
449
+ }
450
+ var dictType = v .get ('Type' );
451
+ return isName (dictType ) && dictType .name == type ;
445
452
}
446
453
447
454
function isArray (v ) {
Original file line number Diff line number Diff line change @@ -63,5 +63,18 @@ describe('util', function() {
63
63
});
64
64
});
65
65
66
+ describe ('isDict' , function () {
67
+ it ('handles empty dictionaries with type check' , function () {
68
+ var dict = new Dict ();
69
+ expect (isDict (dict , 'Page' )).toEqual (false );
70
+ });
71
+
72
+ it ('handles dictionaries with type check' , function () {
73
+ var dict = new Dict ();
74
+ dict .set ('Type' , new Name ('Page' ));
75
+ expect (isDict (dict , 'Page' )).toEqual (true );
76
+ });
77
+ });
78
+
66
79
});
67
80
You can’t perform that action at this time.
0 commit comments