Move the XRefMock in the unit tests to a central location

This patch helps to avoid code duplication for this mock since more unit
tests are depending on it.
This commit is contained in:
Tim van der Meij 2017-07-29 00:35:10 +02:00
parent 783d42ec2b
commit ab820438ae
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
5 changed files with 39 additions and 80 deletions

View file

@ -20,31 +20,12 @@ import {
AnnotationBorderStyleType, AnnotationFieldFlag, AnnotationFlag,
AnnotationType, stringToBytes, stringToUTF8String
} from '../../src/shared/util';
import { Dict, isRef, Name, Ref } from '../../src/core/primitives';
import { Dict, Name, Ref } from '../../src/core/primitives';
import { Lexer, Parser } from '../../src/core/parser';
import { StringStream } from '../../src/core/stream';
import { XRefMock } from './test_utils';
describe('annotation', function() {
function XRefMock(array) {
this.map = Object.create(null);
for (var elem in array) {
var obj = array[elem];
var ref = obj.ref, data = obj.data;
this.map[ref.toString()] = data;
}
}
XRefMock.prototype = {
fetch(ref) {
return this.map[ref.toString()];
},
fetchIfRef(obj) {
if (!isRef(obj)) {
return obj;
}
return this.fetch(obj);
},
};
function PDFManagerMock(params) {
this.docBaseUrl = params.docBaseUrl || null;
}