2016-04-16 01:03:10 +09:00
|
|
|
/* globals expect, it, describe, Dict, isDict, Name, PDFJS,
|
2016-03-03 09:48:21 +09:00
|
|
|
stringToPDFString, removeNullCharacters */
|
2012-06-24 05:35:59 +09:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
describe('util', function() {
|
2013-01-11 09:32:26 +09:00
|
|
|
describe('isDict', function() {
|
|
|
|
it('handles empty dictionaries with type check', function() {
|
|
|
|
var dict = new Dict();
|
|
|
|
expect(isDict(dict, 'Page')).toEqual(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles dictionaries with type check', function() {
|
|
|
|
var dict = new Dict();
|
2014-02-28 13:41:03 +09:00
|
|
|
dict.set('Type', Name.get('Page'));
|
2013-01-11 09:32:26 +09:00
|
|
|
expect(isDict(dict, 'Page')).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-09-10 19:23:45 +09:00
|
|
|
describe('stringToPDFString', function() {
|
|
|
|
it('handles ISO Latin 1 strings', function() {
|
|
|
|
var str = '\x8Dstring\x8E';
|
|
|
|
expect(stringToPDFString(str)).toEqual('\u201Cstring\u201D');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles UTF-16BE strings', function() {
|
|
|
|
var str = '\xFE\xFF\x00\x73\x00\x74\x00\x72\x00\x69\x00\x6E\x00\x67';
|
|
|
|
expect(stringToPDFString(str)).toEqual('string');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('handles empty strings', function() {
|
|
|
|
// ISO Latin 1
|
|
|
|
var str1 = '';
|
|
|
|
expect(stringToPDFString(str1)).toEqual('');
|
|
|
|
|
|
|
|
// UTF-16BE
|
|
|
|
var str2 = '\xFE\xFF';
|
|
|
|
expect(stringToPDFString(str2)).toEqual('');
|
|
|
|
});
|
|
|
|
});
|
2015-09-30 19:59:50 +09:00
|
|
|
|
2016-01-05 05:33:41 +09:00
|
|
|
describe('removeNullCharacters', function() {
|
|
|
|
it('should not modify string without null characters', function() {
|
|
|
|
var str = 'string without null chars';
|
|
|
|
expect(removeNullCharacters(str)).toEqual('string without null chars');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should modify string with null characters', function() {
|
|
|
|
var str = 'string\x00With\x00Null\x00Chars';
|
|
|
|
expect(removeNullCharacters(str)).toEqual('stringWithNullChars');
|
|
|
|
});
|
|
|
|
});
|
2012-06-24 05:35:59 +09:00
|
|
|
});
|