Files
wip-reference/site/tests/landing-ascii.test.mjs
Hare d5a0879142
Reference site / build (push) Canceled after 0s
fix: separate hover and use ASCII glitch transitions
2026-10-10 03:00:08 +09:00

22 lines
1008 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { glitchText } from '../src/lib/landing-ascii.mjs';
const text = '┌────────┐\n│ object │\n└────────┘\n 本文: "sample";';
test('ASCII glitch preserves cells, whitespace and Japanese prose', () => {
const output = glitchText(text, .2, 9, 2);
assert.equal(output.length, text.length);
assert.equal(output.match(/\s/g).join(''), text.match(/\s/g).join(''));
assert.ok(output.includes('本文'));
assert.notEqual(output, text);
});
test('noise is reproducible and changes only with its explicit clock', () => {
assert.equal(glitchText(text, .3, 1, 7), glitchText(text, .3, 1, 7));
assert.notEqual(glitchText(text, .3, 1, 7), glitchText(text, .3, 2, 7));
});
test('transition restores the exact source text at its boundary', () => {
assert.equal(glitchText(text, 1, 99), text);
assert.equal(glitchText(text, 2, 99), text);
assert.equal(glitchText('', .5, 1), '');
});