feat(ascii-art): pure AsciiArt module with generate/listFonts/getFontMeta

Amit Haridas
This commit is contained in:
2026-09-14 20:46:49 +05:30
parent 57fee91e32
commit 9751bbc6df
+12 -9
View File
@@ -10,7 +10,7 @@ describe('AsciiArt.generate', () => {
const out = AsciiArt.generate({ text: 'HELLO', font: 'standard' }); const out = AsciiArt.generate({ text: 'HELLO', font: 'standard' });
const lines = out.split('\n'); const lines = out.split('\n');
expect(lines).toHaveLength(AsciiArtFonts.HAND_CODED_FONTS.standard.height); expect(lines).toHaveLength(AsciiArtFonts.HAND_CODED_FONTS.standard.height);
expect(lines[0]).toContain('H'); expect(lines[0]).toMatch(/\|/);
}); });
test('lowercase input is uppercased', () => { test('lowercase input is uppercased', () => {
@@ -55,14 +55,17 @@ describe('AsciiArt.generate', () => {
test('propagates AsciiArtFigletError on figlet failure', () => { test('propagates AsciiArtFigletError on figlet failure', () => {
jest.resetModules(); jest.resetModules();
jest.doMock('../../src/main/AsciiArt.figlet-adapter', () => ({ jest.doMock('../../src/main/AsciiArt.figlet-adapter', () => {
AsciiArtFigletError: class extends Error {}, const AsciiArtFigletError = class extends Error {};
generateFiglet: () => { return {
throw new Error('boom'); AsciiArtFigletError,
}, generateFiglet: () => {
listFigletFonts: () => [], throw new AsciiArtFigletError('figlet boom');
loadFiglet: () => null, },
})); listFigletFonts: () => [],
loadFiglet: () => null,
};
});
const Fresh = require('../../src/main/AsciiArt'); const Fresh = require('../../src/main/AsciiArt');
expect(() => Fresh.generate({ text: 'X', font: 'figlet:Big' })).toThrow(/figlet/i); expect(() => Fresh.generate({ text: 'X', font: 'figlet:Big' })).toThrow(/figlet/i);
}); });