mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-02 01:29:32 +05:30
Export themes: - Six presets in the export dialog (basic + advanced modes) for PDF/DOCX: Default, Modern, Classic, Sepia, Minimal, Elegant - PDF: LaTeX header (xcolor/titlesec) recolors headings, adds section rules and colored links — core-TeX packages only, hex-literal only (no injection surface) - DOCX: styles.xml surgery recolors Heading1-6/Title/Subtitle/Hyperlink and swaps heading/body fonts; verified end-to-end against a real pandoc-produced docx - Themes ride along in export presets (unknown ids fall back to Default) Windows CI fixes: - pdfjs standardFontDataUrl now a file:// URL (backslash paths failed pdfjs's trailing-slash validation, breaking extractText/extractImages) - sharp temp cleanup EPERM retries; path-separator assertions; pdfjs test timeouts raised; batch suite testTimeout 30s 648/648 tests green; 4.7.1 linux+win artifacts rebuilt.
55 lines
2.1 KiB
JavaScript
55 lines
2.1 KiB
JavaScript
jest.mock('electron', () => ({
|
|
app: { getPath: () => '/fake/userData' },
|
|
}));
|
|
jest.mock('fs', () => ({ existsSync: jest.fn(), statSync: jest.fn() }));
|
|
|
|
const fs = require('fs');
|
|
const MonospaceFontConfig = require('../src/main/MonospaceFontConfig');
|
|
|
|
describe('MonospaceFontConfig', () => {
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
test('returns null when no file exists', () => {
|
|
fs.existsSync.mockReturnValue(false);
|
|
const p = MonospaceFontConfig.getMonoFontTtfPath('jetbrains-mono', 400);
|
|
expect(p).toBeNull();
|
|
});
|
|
|
|
test('returns dev repo path when dev file exists', () => {
|
|
fs.existsSync.mockImplementation(
|
|
(p) => !p.includes('app.asar.unpacked') && p.endsWith('JetBrainsMono-Regular.ttf')
|
|
);
|
|
const p = MonospaceFontConfig.getMonoFontTtfPath('jetbrains-mono', 400);
|
|
// Normalize separators: Windows paths are backslash-joined
|
|
expect(p.split(require('path').sep).join('/')).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')
|
|
);
|
|
const p = MonospaceFontConfig.getMonoFontTtfPath('fira-code', 400);
|
|
expect(p).toContain('app.asar.unpacked');
|
|
expect(p).toContain('FiraCode-Regular.ttf');
|
|
});
|
|
|
|
test('returns null and warns when file is missing', () => {
|
|
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
fs.existsSync.mockReturnValue(false);
|
|
const p = MonospaceFontConfig.getMonoFontTtfPath('fira-code', 700);
|
|
expect(p).toBeNull();
|
|
expect(warn).toHaveBeenCalledWith(expect.stringMatching(/FiraCode-Bold\.ttf/));
|
|
warn.mockRestore();
|
|
});
|
|
|
|
test('ligaturesEnabled maps from settings', () => {
|
|
expect(MonospaceFontConfig.ligaturesEnabled({ monospaceLigatures: true })).toBe(true);
|
|
expect(MonospaceFontConfig.ligaturesEnabled({ monospaceLigatures: false })).toBe(false);
|
|
expect(MonospaceFontConfig.ligaturesEnabled({})).toBe(false);
|
|
});
|
|
});
|