Files
esengine/packages/tools/demos/src/utils.ts

42 lines
1.4 KiB
TypeScript
Raw Normal View History

/**
* @zh Demo
* @en Demo test utility functions
*/
/**
* @zh
* @en Assert condition is true, otherwise throw error
*/
export function assert(condition: boolean, message: string): void {
if (!condition) throw new Error(`FAILED: ${message}`);
console.log(`${message}`);
}
/**
* @zh
* @en Print test section header
*/
export function section(name: string): void {
console.log(`\n▶ ${name}`);
}
/**
* @zh Demo
* @en Print demo start header
*/
export function demoHeader(name: string): void {
console.log('═══════════════════════════════════════');
console.log(` ${name}`);
console.log('═══════════════════════════════════════');
}
/**
* @zh Demo
* @en Print demo end header
*/
export function demoFooter(name: string): void {
console.log('\n═══════════════════════════════════════');
console.log(` ${name}: ALL TESTS PASSED ✓`);
console.log('═══════════════════════════════════════\n');
}