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:
2026-08-23 19:31:33 +05:30
parent 58868eece0
commit 7095b34280
14 changed files with 134 additions and 45 deletions
+26 -8
View File
@@ -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);
});
});
});
+5 -2
View File
@@ -12,7 +12,10 @@ describe('EpubFontEmbedder.patchManifest', () => {
fs.mkdirSync(fixturesDir, { recursive: true });
fs.writeFileSync(fontPath, 'fake-ttf-binary');
const zip = new JSZip();
zip.file('OEBPS/content.opf', '<?xml version="1.0"?><package xmlns="http://www.idpf.org/2007/opf"></package>');
zip.file(
'OEBPS/content.opf',
'<?xml version="1.0"?><package xmlns="http://www.idpf.org/2007/opf"></package>'
);
fs.writeFileSync(epubPath, await zip.generateAsync({ type: 'nodebuffer' }));
});
@@ -28,4 +31,4 @@ describe('EpubFontEmbedder.patchManifest', () => {
expect(opf).toMatch(/<item[^>]*href="OEBPS\/fonts\/fake\.ttf"/);
expect(opf).toMatch(/<item[^>]*media-type="application\/x-font-ttf"/);
});
});
});
+12 -2
View File
@@ -13,14 +13,24 @@ describe('ExportCss.build', () => {
afterAll(() => fs.rmSync(path.dirname(fakeFontPath), { recursive: true, force: true }));
test('emits a self-contained CSS with embedded @font-face', () => {
const css = ExportCss.build({ activeFontPath: fakeFontPath, family: 'JetBrains Mono', weight: 400, ligatures: false });
const css = ExportCss.build({
activeFontPath: fakeFontPath,
family: 'JetBrains Mono',
weight: 400,
ligatures: false,
});
expect(css).toMatch(/@font-face\s*\{[^}]*src:\s*url\('data:font\/woff2;base64,/);
expect(css).toContain("font-family: 'JetBrains Mono'");
expect(css).toMatch(/font-feature-settings:[^;]*liga[^;]*0/);
});
test('falls back to family-only CSS when font path is missing', () => {
const css = ExportCss.build({ activeFontPath: null, family: 'Fira Code', weight: 700, ligatures: true });
const css = ExportCss.build({
activeFontPath: null,
family: 'Fira Code',
weight: 700,
ligatures: true,
});
expect(css).not.toContain('data:font/woff2;');
expect(css).toContain("font-family: 'Fira Code'");
});
+9 -3
View File
@@ -7,7 +7,9 @@ const fs = require('fs');
const MonospaceFontConfig = require('../src/main/MonospaceFontConfig');
describe('MonospaceFontConfig', () => {
afterEach(() => { jest.clearAllMocks(); });
afterEach(() => {
jest.clearAllMocks();
});
test('returns null when no file exists', () => {
fs.existsSync.mockReturnValue(false);
@@ -16,13 +18,17 @@ describe('MonospaceFontConfig', () => {
});
test('returns dev repo path when dev file exists', () => {
fs.existsSync.mockImplementation((p) => !p.includes('app.asar.unpacked') && p.endsWith('JetBrainsMono-Regular.ttf'));
fs.existsSync.mockImplementation(
(p) => !p.includes('app.asar.unpacked') && p.endsWith('JetBrainsMono-Regular.ttf')
);
const p = MonospaceFontConfig.getMonoFontTtfPath('jetbrains-mono', 400);
expect(p).toMatch(/assets\/fonts\/JetBrainsMono-Regular\.ttf$/);
});
test('returns packaged asar.unpacked path when present and file exists', () => {
fs.existsSync.mockImplementation((p) => p.includes('app.asar.unpacked') && p.endsWith('FiraCode-Regular.ttf'));
fs.existsSync.mockImplementation(
(p) => p.includes('app.asar.unpacked') && p.endsWith('FiraCode-Regular.ttf')
);
const p = MonospaceFontConfig.getMonoFontTtfPath('fira-code', 400);
expect(p).toContain('app.asar.unpacked');
expect(p).toContain('FiraCode-Regular.ttf');
+5 -1
View File
@@ -1,4 +1,8 @@
const { getDefaults, getActiveMonoFont, isLigaturesEnabled } = require('../src/main/settings/monospaceSettings');
const {
getDefaults,
getActiveMonoFont,
isLigaturesEnabled,
} = require('../src/main/settings/monospaceSettings');
describe('monospaceSettings', () => {
test('getDefaults returns sane defaults', () => {
+1 -1
View File
@@ -52,4 +52,4 @@ describe('PdfFontHeader.build', () => {
});
expect(tex).toMatch(/\{FiraCode\}/);
});
});
});