mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-24 07:20:16 +05:30
style: apply Prettier formatting
Run after full implementation to enforce 2-space / 100-char / single-quote conventions across all new + adjacent files.
This commit is contained in:
@@ -12,10 +12,22 @@ describe('DocxFontEmbedder.embed', () => {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(fontPath, 'fake-ttf-data');
|
||||
const zip = new JSZip();
|
||||
zip.file('[Content_Types].xml', '<?xml version="1.0"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>');
|
||||
zip.file('_rels/.rels', '<?xml version="1.0"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>');
|
||||
zip.file('word/document.xml', '<?xml version="1.0"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/main"><w:body/></w:document>');
|
||||
zip.file('word/styles.xml', '<?xml version="1.0"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/main"><w:style w:type="character" w:styleId="SourceCode"><w:name w:val="Source Code"/></w:style></w:styles>');
|
||||
zip.file(
|
||||
'[Content_Types].xml',
|
||||
'<?xml version="1.0"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>'
|
||||
);
|
||||
zip.file(
|
||||
'_rels/.rels',
|
||||
'<?xml version="1.0"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>'
|
||||
);
|
||||
zip.file(
|
||||
'word/document.xml',
|
||||
'<?xml version="1.0"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/main"><w:body/></w:document>'
|
||||
);
|
||||
zip.file(
|
||||
'word/styles.xml',
|
||||
'<?xml version="1.0"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/main"><w:style w:type="character" w:styleId="SourceCode"><w:name w:val="Source Code"/></w:style></w:styles>'
|
||||
);
|
||||
fs.writeFileSync(docxPath, await zip.generateAsync({ type: 'nodebuffer' }));
|
||||
});
|
||||
|
||||
@@ -27,7 +39,9 @@ describe('DocxFontEmbedder.embed', () => {
|
||||
]);
|
||||
const zip = await JSZip.loadAsync(fs.readFileSync(out));
|
||||
expect(Object.keys(zip.files).some((f) => f.startsWith('word/fonts/'))).toBe(true);
|
||||
const fontTable = zip.file('word/fontTable.xml') ? await zip.file('word/fontTable.xml').async('string') : '';
|
||||
const fontTable = zip.file('word/fontTable.xml')
|
||||
? await zip.file('word/fontTable.xml').async('string')
|
||||
: '';
|
||||
expect(fontTable).toContain('JetBrains Mono');
|
||||
expect(fontTable).toMatch(/<w:embedRegular/);
|
||||
const styles = await zip.file('word/styles.xml').async('string');
|
||||
@@ -35,10 +49,14 @@ describe('DocxFontEmbedder.embed', () => {
|
||||
});
|
||||
|
||||
test('is idempotent: running twice does not double-embed', async () => {
|
||||
const once = await DocxFontEmbedder.embed(docxPath, [{ path: fontPath, family: 'JetBrains Mono', weight: 400 }]);
|
||||
const twice = await DocxFontEmbedder.embed(once, [{ path: fontPath, family: 'JetBrains Mono', weight: 400 }]);
|
||||
const once = await DocxFontEmbedder.embed(docxPath, [
|
||||
{ path: fontPath, family: 'JetBrains Mono', weight: 400 },
|
||||
]);
|
||||
const twice = await DocxFontEmbedder.embed(once, [
|
||||
{ path: fontPath, family: 'JetBrains Mono', weight: 400 },
|
||||
]);
|
||||
const zip = await JSZip.loadAsync(fs.readFileSync(twice));
|
||||
const fontEntries = Object.keys(zip.files).filter((f) => /^word\/fonts\/[^/]+\.ttf$/.test(f));
|
||||
expect(fontEntries.length).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user