Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { getImploidAsciiArt } from './utils/ascii-art';

describe('CLI Application', () => {
describe('startup', () => {
let originalLog: typeof console.log;
let originalArgv: string[];
let consoleOutput: string[] = [];

beforeEach(() => {
originalLog = console.log;
originalArgv = process.argv;
process.argv = ['node', 'index.js', '--help'];
consoleOutput = [];
console.log = jest.fn((...args) => {
consoleOutput.push(args.map(arg => String(arg)).join(' '));
});
});

afterEach(() => {
console.log = originalLog;
process.argv = originalArgv;
jest.resetModules();
});

it('should display IMPLOID ASCII art on startup', () => {
const expectedArt = getImploidAsciiArt();

try {
jest.isolateModules(() => {
require('./index');
});
} catch (e) {
// The CLI will throw an exit error after displaying help, which is expected
}

expect(console.log).toHaveBeenCalled();
expect(consoleOutput[0]).toBe(expectedArt);
});
});
});
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import { Command } from 'commander';
import { greet } from './commands/greet';
import { getImploidAsciiArt } from './utils/ascii-art';

console.log(getImploidAsciiArt());

const program = new Command();

Expand Down
38 changes: 38 additions & 0 deletions src/utils/ascii-art.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { getImploidAsciiArt } from './ascii-art';

describe('ASCII Art', () => {
describe('getImploidAsciiArt', () => {
it('should return IMPLOID ASCII art as a string', () => {
const art = getImploidAsciiArt();
expect(typeof art).toBe('string');
expect(art).toBeTruthy();
expect(art.length).toBeGreaterThan(0);
});

it('should contain ASCII art representing IMPLOID', () => {
const art = getImploidAsciiArt();
// Check that the ASCII art contains typical ASCII art characters
expect(art).toContain('_');
expect(art).toContain('|');
expect(art).toContain('/');
expect(art).toContain('\\');
// Ensure it has the structure of ASCII art letters
expect(art).toMatch(/[_|/\\]+/);
});

it('should be properly formatted with multiple lines', () => {
const art = getImploidAsciiArt();
const lines = art.split('\n');
expect(lines.length).toBeGreaterThan(1);
});

it('should have consistent line lengths for proper display', () => {
const art = getImploidAsciiArt();
const lines = art.split('\n').filter(line => line.trim() !== '');

for (const line of lines) {
expect(line.length).toBeLessThanOrEqual(80);
}
});
});
});
10 changes: 10 additions & 0 deletions src/utils/ascii-art.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function getImploidAsciiArt(): string {
return `
_____ __ __ _____ _ ____ _____ _____
|_ _| \\/ | __ \\| | / __ \\_ _| __ \\
| | | \\ / | |__) | | | | | || | | | | |
| | | |\\/| | ___/| | | | | || | | | | |
_| |_| | | | | | |___| |__| || |_| |__| |
|_____|_| |_|_| |______\\____/_____|_____/
`;
}