test: harden visual resource rendering
This commit is contained in:
@@ -121,6 +121,75 @@ describe('OneNote rich-content model', () => {
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('retains an embedded-file node as a downloadable lazy resource', () => {
|
||||
const guid = '{22222222-2222-2222-2222-222222222222}';
|
||||
const attachmentId = id(guid, 1);
|
||||
const containerId = id(guid, 2);
|
||||
const payload = Uint8Array.of(1, 2, 3, 4);
|
||||
const attachment = object(
|
||||
attachmentId,
|
||||
JCID.EmbeddedFileNode,
|
||||
{
|
||||
...emptyProps(),
|
||||
objectIds: [compact(2)],
|
||||
properties: {
|
||||
entries: [
|
||||
referenceEntry(PROPERTY.EmbeddedFileContainer, 'one'),
|
||||
bytesEntry(
|
||||
PROPERTY.EmbeddedFileName,
|
||||
Buffer.from('report.txt', 'utf16le')
|
||||
),
|
||||
],
|
||||
},
|
||||
},
|
||||
guid
|
||||
);
|
||||
const container = object(
|
||||
containerId,
|
||||
JCID.EmbeddedFileContainer,
|
||||
emptyProps(),
|
||||
guid
|
||||
);
|
||||
container.fileData = {
|
||||
referenceKind: 'embedded',
|
||||
dataReference: '<ifndf>{22222222-2222-2222-2222-222222222222}',
|
||||
extension: '.txt',
|
||||
blob: { source: payload, offset: 0, size: payload.length },
|
||||
};
|
||||
const resources = new Map();
|
||||
const space: ObjectSpace = {
|
||||
id: id(guid, 0),
|
||||
roots: new Map(),
|
||||
objects: new Map([
|
||||
[exGuidKey(attachment.id), attachment],
|
||||
[exGuidKey(container.id), container],
|
||||
]),
|
||||
};
|
||||
|
||||
const blocks = parseContentObjects([attachmentId], {
|
||||
space,
|
||||
limits: { ...DEFAULT_ONENOTE_PARSER_LIMITS },
|
||||
diagnostics: [],
|
||||
resources,
|
||||
});
|
||||
|
||||
expect(blocks).toEqual([
|
||||
expect.objectContaining({
|
||||
kind: 'attachment',
|
||||
filename: 'report.txt',
|
||||
size: 4,
|
||||
resourceId: exGuidKey(containerId),
|
||||
}),
|
||||
]);
|
||||
expect(resources.get(exGuidKey(containerId))).toMatchObject({
|
||||
kind: 'attachment',
|
||||
extension: 'txt',
|
||||
mediaType: 'text/plain',
|
||||
availability: 'available',
|
||||
size: 4,
|
||||
});
|
||||
});
|
||||
|
||||
it('bounds aggregate ink point expansion', () => {
|
||||
const model = parseOneNoteSectionContent(fixture, {
|
||||
limits: { maxInkPoints: 100 },
|
||||
|
||||
Reference in New Issue
Block a user