| 1 | import test from 'node:test' ; |
| 2 | import assert from 'node:assert/strict' ; |
| 3 | import {avatar, recipe} from '../src/index.js' ; |
| 4 | import {validate} from './helpers.js' ; |
| 5 | test('masks renders a distinct grammar with sampled geometric variety' , () => { |
| 6 | const shapes = new Set(); |
| 7 | let n = 0; |
| 8 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 9 | const seed = `visual-${i}` ; |
| 10 | if (recipe(seed).family !== 'masks' ) continue; |
| 11 | const svg = avatar(seed); |
| 12 | validate(svg); |
| 13 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 14 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 15 | n++; |
| 16 | } |
| 17 | assert.equal(n, 96); |
| 18 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 19 | }); |
| 20 | test('creatures renders a distinct grammar with sampled geometric variety' , () => { |
| 21 | const shapes = new Set(); |
| 22 | let n = 0; |
| 23 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 24 | const seed = `visual-${i}` ; |
| 25 | if (recipe(seed).family !== 'creatures' ) continue; |
| 26 | const svg = avatar(seed); |
| 27 | validate(svg); |
| 28 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 29 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 30 | n++; |
| 31 | } |
| 32 | assert.equal(n, 96); |
| 33 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 34 | }); |
| 35 | test('botanical renders a distinct grammar with sampled geometric variety' , () => { |
| 36 | const shapes = new Set(); |
| 37 | let n = 0; |
| 38 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 39 | const seed = `visual-${i}` ; |
| 40 | if (recipe(seed).family !== 'botanical' ) continue; |
| 41 | const svg = avatar(seed); |
| 42 | validate(svg); |
| 43 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 44 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 45 | n++; |
| 46 | } |
| 47 | assert.equal(n, 96); |
| 48 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 49 | }); |
| 50 | test('orbital renders a distinct grammar with sampled geometric variety' , () => { |
| 51 | const shapes = new Set(); |
| 52 | let n = 0; |
| 53 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 54 | const seed = `visual-${i}` ; |
| 55 | if (recipe(seed).family !== 'orbital' ) continue; |
| 56 | const svg = avatar(seed); |
| 57 | validate(svg); |
| 58 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 59 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 60 | n++; |
| 61 | } |
| 62 | assert.equal(n, 96); |
| 63 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 64 | }); |
| 65 | test('landscapes renders a distinct grammar with sampled geometric variety' , () => { |
| 66 | const shapes = new Set(); |
| 67 | let n = 0; |
| 68 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 69 | const seed = `visual-${i}` ; |
| 70 | if (recipe(seed).family !== 'landscapes' ) continue; |
| 71 | const svg = avatar(seed); |
| 72 | validate(svg); |
| 73 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 74 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 75 | n++; |
| 76 | } |
| 77 | assert.equal(n, 96); |
| 78 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 79 | }); |
| 80 | test('glyphs renders a distinct grammar with sampled geometric variety' , () => { |
| 81 | const shapes = new Set(); |
| 82 | let n = 0; |
| 83 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 84 | const seed = `visual-${i}` ; |
| 85 | if (recipe(seed).family !== 'glyphs' ) continue; |
| 86 | const svg = avatar(seed); |
| 87 | validate(svg); |
| 88 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 89 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 90 | n++; |
| 91 | } |
| 92 | assert.equal(n, 96); |
| 93 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 94 | }); |
| 95 | test('woven renders a distinct grammar with sampled geometric variety' , () => { |
| 96 | const shapes = new Set(); |
| 97 | let n = 0; |
| 98 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 99 | const seed = `visual-${i}` ; |
| 100 | if (recipe(seed).family !== 'woven' ) continue; |
| 101 | const svg = avatar(seed); |
| 102 | validate(svg); |
| 103 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 104 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 105 | n++; |
| 106 | } |
| 107 | assert.equal(n, 96); |
| 108 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 109 | }); |
| 110 | test('machines renders a distinct grammar with sampled geometric variety' , () => { |
| 111 | const shapes = new Set(); |
| 112 | let n = 0; |
| 113 | for (let i = 0; n < 96 && i < 10000; i++) { |
| 114 | const seed = `visual-${i}` ; |
| 115 | if (recipe(seed).family !== 'machines' ) continue; |
| 116 | const svg = avatar(seed); |
| 117 | validate(svg); |
| 118 | assert(svg.length > 450, 'family needs a composed silhouette, not a blank tile' ); |
| 119 | shapes.add(svg.replace(/#[0-9a-f]{6}/g, '#COLOR')); |
| 120 | n++; |
| 121 | } |
| 122 | assert.equal(n, 96); |
| 123 | assert(shapes.size >= 80, `only ${shapes.size} distinct sampled geometries` ); |
| 124 | }); |