mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 17:29:29 +05:30
feat(ascii-art): pure AsciiArt module with generate/listFonts/getFontMeta
Amit Haridas
This commit is contained in:
@@ -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 {};
|
||||||
|
return {
|
||||||
|
AsciiArtFigletError,
|
||||||
generateFiglet: () => {
|
generateFiglet: () => {
|
||||||
throw new Error('boom');
|
throw new AsciiArtFigletError('figlet boom');
|
||||||
},
|
},
|
||||||
listFigletFonts: () => [],
|
listFigletFonts: () => [],
|
||||||
loadFiglet: () => null,
|
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);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user