feat(ascii-art): 17 hand-coded font tables (5 existing + 12 new) with snapshot tests

Amit Haridas
This commit is contained in:
2026-09-14 20:27:03 +05:30
parent 3fbb47000e
commit 5385e159ed
3 changed files with 3615 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,167 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`AsciiArt.fonts HELLO snapshot per font ansi-shadow 1`] = `
"██╗ ██╗███████╗██╗ ██╗ ██████╗
██║ ██║██╔════╝██║ ██║ ██╔═══██╗
███████║█████╗ ██║ ██║ ██║ ██║
██╔══██║██╔══╝ ██║ ██║ ██║ ██║
██║ ██║███████╗███████╗███████╗╚██████╔╝
╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═════╝
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font banner 1`] = `
" ## ## ####### ## ## #####
## ## ## ## ## ## ##
## ## ## ## ## ## ##
####### ##### ## ## ## ##
## ## ## ## ## ## ##
## ## ## ## ## ## ##
## ## ####### ####### ####### ##### "
`;
exports[`AsciiArt.fonts HELLO snapshot per font big 1`] = `
" _ _ ______ _ _ ____
| | | | | ____| | | | | / __ \\
| |__| | | |__ | | | | | | | |
| __ | | __| | | | | | | | |
| | | | | |____ | |____ | |____ | |__| |
|_| |_| |______| |______| |______| \\____/
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font block 1`] = `
"██╗ ██╗███████╗██╗ ██╗ ██████╗
██║ ██║██╔════╝██║ ██║ ██╔══██╗
███████║█████╗ ██║ ██║ ██║ ██║
██╔══██║██╔══╝ ██║ ██║ ██║ ██║
██║ ██║███████╗███████╗███████╗╚██████╔╝
╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═════╝ "
`;
exports[`AsciiArt.fonts HELLO snapshot per font bubble 1`] = `
" Ⓗ Ⓔ Ⓛ Ⓛ Ⓞ
Ⓗ Ⓗ Ⓔ Ⓔ Ⓛ Ⓛ Ⓛ Ⓛ Ⓞ Ⓞ
ⒽⒽⒽⒽⒽⒺⒺⒺⒺⒺⓁⓁⓁⓁⓁⓁⓁⓁⓁⓁⓄⓄⓄⓄⓄ
Ⓗ ⒽⒺ ⒺⓁ ⓁⓁ ⓁⓄ Ⓞ
Ⓗ ⒽⒺ ⒺⓁ ⓁⓁ ⓁⓄ Ⓞ"
`;
exports[`AsciiArt.fonts HELLO snapshot per font calvin-s 1`] = `
" __ __ _______ ___ ___ _______
| | | || || | | | | |
| |_| || ___|| | | | | _ |
| || |___ | | | | | | | |
| || ___|| |___ | |___ | |_| |
| _ || |___ | || || |
|__| |__||_______||_______||_______||_______|"
`;
exports[`AsciiArt.fonts HELLO snapshot per font digital 1`] = `
"▐ ▐ ▐▌▌▌▌ ▐ ▐ ▐▌▌▌▐
▐ ▐ ▐ ▐ ▐ ▐ ▐
▐▌▌▌▐ ▐▌▌▌ ▐ ▐ ▐ ▐
▐ ▐ ▐ ▐ ▐ ▐ ▐
▐ ▐ ▐▌▌▌▌ ▐ ▐ ▐ ▐
▐ ▐ ▐ ▐▌▌▌▌ ▐▌▌▌▌ ▐▌▌▌▐
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font isometric1 1`] = `
" ___ ___ ___ ___ ___
/\\__\\ /\\ \\ /\\__\\ /\\__\\ /\\ \\
/:/__/_ /::\\ \\ /:/ / /:/ / /::\\ \\
/::\\/\\__\\ /::\\:\\__\\ /:/__/ /:/__/ /:/\\:\\__\\
\\/\\::/ / \\:\\:\\/ / \\:\\ \\ \\:\\ \\ \\:\\/:/ /
/:/ / \\:\\/ / \\:\\__\\ \\:\\__\\ \\::/ /
\\/__/ \\/__/ \\/__/ \\/__/ \\/__/ "
`;
exports[`AsciiArt.fonts HELLO snapshot per font isometric2 1`] = `
"'##::::'##:'########:'##:::::::'##::::::::'#######::
##:::: ##: ##.....:: ##::::::: ##:::::::'##.... ##:
##:::: ##: ##::::::: ##::::::: ##::::::: ##:::: ##:
#########: ######::: ##::::::: ##::::::: ##:::: ##:
##.... ##: ##...:::: ##::::::: ##::::::: ##:::: ##:
##:::: ##: ##::::::: ##::::::: ##::::::: ##:::: ##:
##:::: ##: ########: ########: ########:. #######::
..:::::..::........::........::........:::.......:::"
`;
exports[`AsciiArt.fonts HELLO snapshot per font isometric3 1`] = `
" _ _ ____ _ _ ____
FJ L] F ___J FJ FJ F __ ]
J |__| L J |___: J | J | J |--| L
| __ | | _____| | | | | | | | |
F L__J J F L____: F L_____ F L_____ F L__J J
J__L J__L J________L J________L J________L J\\______/F
|__L J__| |________| |________| |________| J______F
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font isometric4 1`] = `
"
@@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@
@@! @@@ @@! @@! @@! @@! @@@
@!@!@!@! @!!!:! @!! @!! @!@ !@!
!!: !!! !!: !!: !!: !!: !!!
: : : : :: :: : ::.: : : ::.: : : :. :
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font lean 1`] = `
"
_/ _/ _/_/_/_/ _/ _/ _/_/
_/ _/ _/ _/ _/ _/ _/
_/_/_/_/ _/_/_/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/
_/ _/ _/_/_/_/ _/_/_/_/ _/_/_/_/ _/_/
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font slant 1`] = `
" __ __ ______ __ __ ____
/ / / / / ____/ / / / / / __ \\
/ /_/ / / __/ / / / / / / / /
/ __ / / /___ / /___ / /___/ /_/ /
/_/ /_/ /_____/ /_____//_____/\\____/
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font small 1`] = `
" _ _ ___ _ _ ___
| || | | __| | | | | / _ \\
| __ | | _| | |__ | |__ | (_) |
|_||_| |___| |____| |____| \\___/
"
`;
exports[`AsciiArt.fonts HELLO snapshot per font standard 1`] = `
"| |_____| | ___
| || | | / \\
|___||___ | | | |
| || | | | |
| ||____|____|____\\___/"
`;
exports[`AsciiArt.fonts HELLO snapshot per font three-d 1`] = `
" ** ** ******** ** ** *******
/** /**/**///// /** /** **/////**
/** /**/** /** /** ** //**
/**********/******* /** /** /** /**
/**//////**/**//// /** /** /** /**
/** /**/** /** /** //** **
/** /**/********/********/******** //*******
// // //////// //////// //////// /////// "
`;
exports[`AsciiArt.fonts HELLO snapshot per font three-x-five 1`] = `
"
# # ### # # #
# # # # # # #
### ## # # # #
# # # # # # #
# # ### ### ### # "
`;
+80
View File
@@ -0,0 +1,80 @@
/**
* @jest-environment node
*
* Per-font snapshot tests for the 17 hand-coded ASCII art fonts. Snapshots
* are the safety net that catches drift when the font tables are hand-edited.
* Line endings are normalized to \n and trailing whitespace is trimmed so
* editor auto-trim does not produce spurious diffs.
*/
const AsciiArtFonts = require('../../src/main/AsciiArt.fonts');
const FONT_IDS = Object.freeze([
// 5 existing
'standard',
'banner',
'block',
'bubble',
'digital',
// 12 new
'big',
'small',
'lean',
'slant',
'isometric1',
'isometric2',
'isometric3',
'isometric4',
'three-d',
'three-x-five',
'ansi-shadow',
'calvin-s',
]);
const normalize = (s) => s.replace(/\r\n/g, '\n').replace(/[ \t]+\n/g, '\n');
describe('AsciiArt.fonts table shape', () => {
test.each(FONT_IDS)('%s has height and chars for A-Z 0-9 and space', (id) => {
const font = AsciiArtFonts.HAND_CODED_FONTS[id];
expect(font).toBeDefined();
expect(typeof font.height).toBe('number');
expect(font.height).toBeGreaterThanOrEqual(4);
expect(font.height).toBeLessThanOrEqual(8);
expect(typeof font.chars).toBe('object');
for (const ch of 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 '.split('')) {
expect(font.chars[ch]).toBeDefined();
expect(font.chars[ch]).toHaveLength(font.height);
for (const line of font.chars[ch]) {
expect(typeof line).toBe('string');
}
}
});
});
describe('AsciiArt.fonts HELLO snapshot per font', () => {
test.each(FONT_IDS)('%s', (id) => {
const font = AsciiArtFonts.HAND_CODED_FONTS[id];
const lines = Array(font.height).fill('');
for (const ch of 'HELLO') {
const glyph = font.chars[ch] || font.chars[' '];
for (let i = 0; i < font.height; i++) lines[i] += glyph[i];
}
expect(normalize(lines.join('\n'))).toMatchSnapshot();
});
});
describe('AsciiArt.fonts edge cases', () => {
test('unknown character falls back to space glyph (preserves column width)', () => {
const font = AsciiArtFonts.HAND_CODED_FONTS.standard;
const fallback = font.chars[' '];
const unknown = font.chars['é'];
expect(unknown).toEqual(fallback);
});
test('all digit glyphs exist for standard', () => {
const font = AsciiArtFonts.HAND_CODED_FONTS.standard;
for (const d of '0123456789') {
expect(font.chars[d]).toBeDefined();
expect(font.chars[d]).toHaveLength(font.height);
}
});
});