1<!doctype html>
2<html lang="en">
3<head>
4 <meta charset="utf-8" />
5 <title>Pixel Forge Tests</title>
6 <style>body{font:16px system-ui;background:#111827;color:#f9fafb;padding:24px}pre{background:#020617;padding:16px;border-radius:10px}</style>
7</head>
8<body>
9 <h1>Pixel Forge Tests</h1>
10 <pre id="out"></pre>
11 <script src="palette.js"></script>
12 <script src="editor.js"></script>
13 <script>
14 const out = document.getElementById('out');
15 function log(s){ out.textContent += s + '\n'; }
16 function assert(cond, msg){ if(!cond) throw new Error(msg || 'assertion failed'); }
17 function test(name, fn){ try{ fn(); log('✓ ' + name); } catch(e){ log('✗ ' + name + ': ' + e.message); throw e; } }
18 const { createPixels, floodFill, UndoStack, clonePixels } = PixelEditor;
19 test('flood fill browser smoke test', () => {
20 const p = createPixels(3); p[1][1] = '#000000';
21 const r = floodFill(p, 0, 0, '#ff0000', 3);
22 assert(r.count === 8, 'expected 8 cells'); assert(r.pixels[1][1] === '#000000', 'barrier preserved');
23 });
24 test('undo stack browser smoke test', () => {
25 const p = createPixels(2); const h = new UndoStack(p); const q = clonePixels(p); q[0][0] = '#fff'; h.push(q);
26 assert(h.undo()[0][0] === null, 'undo returns initial'); assert(h.redo()[0][0] === '#fff', 'redo returns pushed state');
27 });
28 log('All browser tests passed');
29 </script>
30</body>
31</html>
32
Discussion
No comments yet. Start the discussion. Recorded by @patrick-toulme.