@shipload/item-renderer 0.2.3 → 1.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +47 -49
- package/src/assets/stardust-base64.ts +1 -1
- package/src/errors.ts +14 -14
- package/src/fonts/index.ts +24 -24
- package/src/fonts/load-bun.ts +12 -12
- package/src/index.ts +31 -31
- package/src/links.ts +13 -13
- package/src/meta.ts +26 -26
- package/src/payload/base64url.ts +21 -21
- package/src/payload/codec.ts +19 -19
- package/src/primitives/category-icon.ts +88 -86
- package/src/primitives/compact-row.ts +32 -32
- package/src/primitives/divider.ts +14 -14
- package/src/primitives/icon-hex.ts +36 -36
- package/src/primitives/module-slot.ts +131 -131
- package/src/primitives/panel.ts +18 -18
- package/src/primitives/quantity-badge.ts +32 -32
- package/src/primitives/span-paragraph.ts +56 -56
- package/src/primitives/stat-bar.ts +72 -72
- package/src/primitives/svg.ts +16 -16
- package/src/primitives/text.ts +33 -33
- package/src/primitives/wrap.ts +19 -19
- package/src/render.ts +20 -20
- package/src/templates/_shared.ts +5 -5
- package/src/templates/component.ts +124 -124
- package/src/templates/index.ts +23 -23
- package/src/templates/item-cell.ts +84 -84
- package/src/templates/module.ts +182 -181
- package/src/templates/packed-entity.ts +22 -22
- package/src/templates/resource.ts +136 -134
- package/src/templates/ship-panel.ts +122 -118
- package/src/templates/social-card.ts +36 -36
- package/src/tokens/colors.ts +42 -42
- package/src/tokens/index.ts +6 -6
- package/src/tokens/spacing.ts +9 -9
- package/src/tokens/typography.ts +18 -18
- package/.claude/settings.local.json +0 -6
- package/.github/workflows/ci.yml +0 -14
- package/.gitignore +0 -6
- package/Makefile +0 -50
- package/biome.json +0 -18
- package/bun.lock +0 -123
- package/scripts/check-bundle-size.ts +0 -37
- package/scripts/copy-fonts.ts +0 -41
- package/scripts/preview.ts +0 -41
- package/test/__image_snapshots__/.gitkeep +0 -0
- package/test/__image_snapshots__/component-hull-plates.diff.png +0 -0
- package/test/__image_snapshots__/component-hull-plates.png +0 -0
- package/test/__image_snapshots__/module-engine-t1.diff.png +0 -0
- package/test/__image_snapshots__/module-engine-t1.png +0 -0
- package/test/__image_snapshots__/module-storage-t1.diff.png +0 -0
- package/test/__image_snapshots__/module-storage-t1.png +0 -0
- package/test/__image_snapshots__/packed-entity-ship-t1-only-engine.diff.png +0 -0
- package/test/__image_snapshots__/packed-entity-ship-t1-only-engine.png +0 -0
- package/test/__image_snapshots__/packed-entity-ship-t1-two-modules.diff.png +0 -0
- package/test/__image_snapshots__/packed-entity-ship-t1-two-modules.png +0 -0
- package/test/__image_snapshots__/resource-ore-t1.diff.png +0 -0
- package/test/__image_snapshots__/resource-ore-t1.png +0 -0
- package/test/__snapshots__/templates-component.test.ts.snap +0 -5
- package/test/__snapshots__/templates-item-cell.test.ts.snap +0 -9
- package/test/__snapshots__/templates-module.test.ts.snap +0 -17
- package/test/__snapshots__/templates-packed-entity.test.ts.snap +0 -5
- package/test/__snapshots__/templates-resource.test.ts.snap +0 -7
- package/test/base64url.test.ts +0 -33
- package/test/codec.test.ts +0 -34
- package/test/errors.test.ts +0 -24
- package/test/fixtures/cargo-items.ts +0 -122
- package/test/fonts.test.ts +0 -28
- package/test/links-meta.test.ts +0 -43
- package/test/pixel.test.ts +0 -69
- package/test/primitives-category-icon.test.ts +0 -86
- package/test/primitives-compact-row.test.ts +0 -44
- package/test/primitives-domain.test.ts +0 -83
- package/test/primitives-layout.test.ts +0 -56
- package/test/primitives-module-slot.test.ts +0 -88
- package/test/render.test.ts +0 -43
- package/test/sanity.test.ts +0 -6
- package/test/sdk-link.test.ts +0 -19
- package/test/snapshots/.gitkeep +0 -0
- package/test/svg.test.ts +0 -30
- package/test/templates-component.test.ts +0 -36
- package/test/templates-dispatch.test.ts +0 -35
- package/test/templates-item-cell.test.ts +0 -94
- package/test/templates-module.test.ts +0 -63
- package/test/templates-packed-entity.test.ts +0 -47
- package/test/templates-resource.test.ts +0 -71
- package/test/templates-ship-panel.test.ts +0 -91
- package/test/tokens.test.ts +0 -34
- package/tsconfig.json +0 -20
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
-
|
|
3
|
-
exports[`matches the committed engineT1 snapshot: module-engineT1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="174" viewBox="0 0 280 174"><rect x="0.5" y="0.5" width="279" height="173" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#4a8abf" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#4a8abf" text-anchor="middle">00</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Engine</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#4a8abf" letter-spacing="1">ENGINE</text><text x="14" y="132" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">generates </tspan><tspan fill="#f4c96b">700</tspan><tspan fill="#8f98a8"> thrust for travel</tspan></text><text x="14" y="146" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">while draining </tspan><tspan fill="#f4c96b">45</tspan><tspan fill="#8f98a8"> energy per</tspan></text><text x="14" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">distance travelled</tspan></text></svg>"`;
|
|
4
|
-
|
|
5
|
-
exports[`matches the committed generatorT1 snapshot: module-generatorT1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="174" viewBox="0 0 280 174"><rect x="0.5" y="0.5" width="279" height="173" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#22c55e" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#22c55e" text-anchor="middle">01</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Generator</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#22c55e" letter-spacing="1">GENERATOR</text><text x="14" y="132" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">holds </tspan><tspan fill="#f4c96b">450</tspan><tspan fill="#8f98a8"> maximum energy and</tspan></text><text x="14" y="146" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">restores </tspan><tspan fill="#f4c96b">3</tspan><tspan fill="#8f98a8"> per second while</tspan></text><text x="14" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">recharging</tspan></text></svg>"`;
|
|
6
|
-
|
|
7
|
-
exports[`matches the committed gathererT1 snapshot: module-gathererT1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="188" viewBox="0 0 280 188"><rect x="0.5" y="0.5" width="279" height="187" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#f59e0b" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#f59e0b" text-anchor="middle">02</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Gatherer</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#f59e0b" letter-spacing="1">GATHERER</text><text x="14" y="132" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">mines resources at </tspan><tspan fill="#f4c96b">600</tspan><tspan fill="#8f98a8"> speed to a</tspan></text><text x="14" y="146" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">max depth of </tspan><tspan fill="#f4c96b">350</tspan><tspan fill="#8f98a8"> with </tspan><tspan fill="#f4c96b">200</tspan><tspan fill="#8f98a8"> gather</tspan></text><text x="14" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">speed while draining </tspan><tspan fill="#f4c96b">300</tspan><tspan fill="#8f98a8"> energy per</tspan></text><text x="14" y="174" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">second</tspan></text></svg>"`;
|
|
8
|
-
|
|
9
|
-
exports[`matches the committed loaderT1 snapshot: module-loaderT1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="160" viewBox="0 0 280 160"><rect x="0.5" y="0.5" width="279" height="159" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#eab308" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#eab308" text-anchor="middle">03</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Loader</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#eab308" letter-spacing="1">LOADER</text><text x="14" y="132" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#f4c96b">1</tspan><tspan fill="#8f98a8"> loader that generates </tspan><tspan fill="#f4c96b">2</tspan><tspan fill="#8f98a8"> thrust</tspan></text><text x="14" y="146" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">with a weight of </tspan><tspan fill="#f4c96b">500</tspan><tspan fill="#8f98a8"> per unit</tspan></text></svg>"`;
|
|
10
|
-
|
|
11
|
-
exports[`matches the committed crafterT1 snapshot: module-crafterT1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="160" viewBox="0 0 280 160"><rect x="0.5" y="0.5" width="279" height="159" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#a855f7" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#a855f7" text-anchor="middle">04</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Manufacturing</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#a855f7" letter-spacing="1">MANUFACTURING</text><text x="14" y="132" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">manufactures items at </tspan><tspan fill="#f4c96b">580</tspan><tspan fill="#8f98a8"> speed</tspan></text><text x="14" y="146" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">while draining </tspan><tspan fill="#f4c96b">15</tspan><tspan fill="#8f98a8"> energy per second</tspan></text></svg>"`;
|
|
12
|
-
|
|
13
|
-
exports[`matches the committed storageT1 snapshot: module-storageT1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="146" viewBox="0 0 280 146"><rect x="0.5" y="0.5" width="279" height="145" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#14b8a6" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#14b8a6" text-anchor="middle">05</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Storage</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#14b8a6" letter-spacing="1">STORAGE</text><text x="14" y="132" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">boosts cargo capacity by </tspan><tspan fill="#f4c96b">16</tspan><tspan fill="#8f98a8">%</tspan></text></svg>"`;
|
|
14
|
-
|
|
15
|
-
exports[`matches the committed haulerT1 snapshot: module-haulerT1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="174" viewBox="0 0 280 174"><rect x="0.5" y="0.5" width="279" height="173" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#f97316" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#f97316" text-anchor="middle">06</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Hauler</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#f97316" letter-spacing="1">HAULER</text><text x="14" y="132" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">locks onto up to </tspan><tspan fill="#f4c96b">2</tspan><tspan fill="#8f98a8"> targets at </tspan><tspan fill="#f4c96b">2,000</tspan></text><text x="14" y="146" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">efficiency while draining </tspan><tspan fill="#f4c96b">15</tspan><tspan fill="#8f98a8"> energy</tspan></text><text x="14" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">per distance travelled per target</tspan></text></svg>"`;
|
|
16
|
-
|
|
17
|
-
exports[`renderModule ranges mode matches snapshot: module-ranges 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="132" viewBox="0 0 280 132"><rect x="0.5" y="0.5" width="279" height="131" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#4a8abf" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#4a8abf" text-anchor="middle">00</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Engine</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Type</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">MODULE · T1</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">0</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="112" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#4a8abf" letter-spacing="1">ENGINE</text></svg>"`;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
-
|
|
3
|
-
exports[`matches the committed Ship T1 (two modules) snapshot: packed-entity-ship-t1-two-modules.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="314" viewBox="0 0 280 314"><rect x="0.5" y="0.5" width="279" height="313" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#f4c96b" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#f4c96b" text-anchor="middle">SH</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Ship (Packed)</text><text x="14" y="62" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#8f98a8" letter-spacing="1">HULL</text><text x="14" y="80" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="80" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="700" fill="#e6e8ec" text-anchor="end">25,000</text><line x1="14" x2="266" y1="86" y2="86" stroke="#2a3340" stroke-width="1"/><text x="14" y="102" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Capacity</text><text x="266" y="102" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="700" fill="#e6e8ec" text-anchor="end">1,000,000</text><line x1="14" x2="266" y1="108" y2="108" stroke="#2a3340" stroke-width="1"/><polygon points="20,125 25,130 20,135 15,130" fill="#2fd6d1"/><text x="34" y="133" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan font-weight="600" fill="#e6e8ec">Engine: </tspan><tspan fill="#8f98a8">generates </tspan><tspan fill="#f4c96b">598</tspan><tspan fill="#8f98a8"> thrust for</tspan></text><text x="34" y="147" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">travel while draining </tspan><tspan fill="#f4c96b">47</tspan><tspan fill="#8f98a8"> energy per</tspan></text><text x="34" y="161" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">distance travelled</tspan></text><polygon points="20,177 25,182 20,187 15,182" fill="#2fd6d1"/><text x="34" y="185" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan font-weight="600" fill="#e6e8ec">Generator: </tspan><tspan fill="#8f98a8">holds </tspan><tspan fill="#f4c96b">456</tspan><tspan fill="#8f98a8"> maximum energy</tspan></text><text x="34" y="199" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">and restores </tspan><tspan fill="#f4c96b">3</tspan><tspan fill="#8f98a8"> per second while</tspan></text><text x="34" y="213" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">recharging</tspan></text><polygon points="20,229 25,234 20,239 15,234" fill="none" stroke="#2a3340" stroke-width="1"/><text x="34" y="237" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#5b6373">Empty module</text><polygon points="20,253 25,258 20,263 15,258" fill="none" stroke="#2a3340" stroke-width="1"/><text x="34" y="261" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#5b6373">Empty module</text><polygon points="20,277 25,282 20,287 15,282" fill="none" stroke="#2a3340" stroke-width="1"/><text x="34" y="285" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#5b6373">Empty module</text></svg>"`;
|
|
4
|
-
|
|
5
|
-
exports[`matches the committed Ship T1 (only engine) snapshot: packed-entity-ship-t1-only-engine.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="286" viewBox="0 0 280 286"><rect x="0.5" y="0.5" width="279" height="285" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#f4c96b" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#f4c96b" text-anchor="middle">SH</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Ship (Packed)</text><text x="14" y="62" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="11" font-weight="700" fill="#8f98a8" letter-spacing="1">HULL</text><text x="14" y="80" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="80" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="700" fill="#e6e8ec" text-anchor="end">25,000</text><line x1="14" x2="266" y1="86" y2="86" stroke="#2a3340" stroke-width="1"/><text x="14" y="102" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Capacity</text><text x="266" y="102" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="700" fill="#e6e8ec" text-anchor="end">1,000,000</text><line x1="14" x2="266" y1="108" y2="108" stroke="#2a3340" stroke-width="1"/><polygon points="20,125 25,130 20,135 15,130" fill="#2fd6d1"/><text x="34" y="133" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan font-weight="600" fill="#e6e8ec">Engine: </tspan><tspan fill="#8f98a8">generates </tspan><tspan fill="#f4c96b">598</tspan><tspan fill="#8f98a8"> thrust for</tspan></text><text x="34" y="147" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">travel while draining </tspan><tspan fill="#f4c96b">47</tspan><tspan fill="#8f98a8"> energy per</tspan></text><text x="34" y="161" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12"><tspan fill="#8f98a8">distance travelled</tspan></text><polygon points="20,177 25,182 20,187 15,182" fill="none" stroke="#2a3340" stroke-width="1"/><text x="34" y="185" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#5b6373">Empty module</text><polygon points="20,201 25,206 20,211 15,206" fill="none" stroke="#2a3340" stroke-width="1"/><text x="34" y="209" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#5b6373">Empty module</text><polygon points="20,225 25,230 20,235 15,230" fill="none" stroke="#2a3340" stroke-width="1"/><text x="34" y="233" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#5b6373">Empty module</text><polygon points="20,249 25,254 20,259 15,254" fill="none" stroke="#2a3340" stroke-width="1"/><text x="34" y="257" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#5b6373">Empty module</text></svg>"`;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
|
2
|
-
|
|
3
|
-
exports[`matches the committed Crude Ore snapshot: resource-ore-t1.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="190" viewBox="0 0 280 190"><rect x="0.5" y="0.5" width="279" height="189" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#C26D3F" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#C26D3F" text-anchor="middle">01</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Crude Ore</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Category</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">Ore</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">30,000</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="108" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#C26D3F">STR</text><text x="36" y="108" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Strength</text><text x="266" y="108" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="14" font-weight="700" fill="#C26D3F" text-anchor="end">959</text><rect x="14" y="114" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><rect x="14" y="114" width="236" height="4" rx="2" ry="2" fill="#C26D3F"/><text x="14" y="134" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#C26D3F">TOL</text><text x="36" y="134" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Tolerance</text><text x="266" y="134" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="14" font-weight="700" fill="#C26D3F" text-anchor="end">340</text><rect x="14" y="140" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><rect x="14" y="140" width="83" height="4" rx="2" ry="2" fill="#C26D3F"/><text x="14" y="160" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#C26D3F">DEN</text><text x="36" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Density</text><text x="266" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="14" font-weight="700" fill="#C26D3F" text-anchor="end">59</text><rect x="14" y="166" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><rect x="14" y="166" width="237" height="4" rx="2" ry="2" fill="#C26D3F"/></svg>"`;
|
|
4
|
-
|
|
5
|
-
exports[`matches the committed Dense Gas snapshot: resource-gas-t2.svg 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="190" viewBox="0 0 280 190"><rect x="0.5" y="0.5" width="279" height="189" rx="10" ry="10" fill="#11141a" stroke="#4ade80" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#B8E4A0" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#B8E4A0" text-anchor="middle">02</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Dense Gas</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Category</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">Gas</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">2,000</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="108" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#B8E4A0">VOL</text><text x="36" y="108" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Volatility</text><text x="266" y="108" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="14" font-weight="700" fill="#B8E4A0" text-anchor="end">898</text><rect x="14" y="114" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><rect x="14" y="114" width="221" height="4" rx="2" ry="2" fill="#B8E4A0"/><text x="14" y="134" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#B8E4A0">REA</text><text x="36" y="134" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Reactivity</text><text x="266" y="134" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="14" font-weight="700" fill="#B8E4A0" text-anchor="end">728</text><rect x="14" y="140" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><rect x="14" y="140" width="179" height="4" rx="2" ry="2" fill="#B8E4A0"/><text x="14" y="160" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#B8E4A0">THM</text><text x="36" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Thermal</text><text x="266" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="14" font-weight="700" fill="#B8E4A0" text-anchor="end">399</text><rect x="14" y="166" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><rect x="14" y="166" width="98" height="4" rx="2" ry="2" fill="#B8E4A0"/></svg>"`;
|
|
6
|
-
|
|
7
|
-
exports[`renderResource ranges mode matches snapshot: resource-ranges 1`] = `"<svg xmlns="http://www.w3.org/2000/svg" width="280" height="190" viewBox="0 0 280 190"><rect x="0.5" y="0.5" width="279" height="189" rx="10" ry="10" fill="#11141a" stroke="#8b8b8b" stroke-width="1"/><polygon points="14.0,29.0 20.4,18.0 33.1,18.0 39.4,29.0 33.1,40.0 20.4,40.0" fill="none" stroke="#C26D3F" stroke-width="1.5"/><text x="26.701700000000002" y="32" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="9" font-weight="700" fill="#C26D3F" text-anchor="middle">01</text><text x="48" y="36" font-family=""Orbitron", "Orbitron Variable", system-ui, sans-serif" font-size="16" font-weight="700" fill="#e6e8ec">Crude Ore</text><text x="14" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Category</text><text x="266" y="66" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">Ore</text><text x="14" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#8f98a8">Mass</text><text x="266" y="82" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6e8ec" text-anchor="end">30,000</text><line x1="14" x2="266" y1="96" y2="96" stroke="#1e242e" stroke-width="1"/><text x="14" y="108" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#C26D3F">STR</text><text x="36" y="108" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Strength</text><rect x="14" y="114" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><text x="14" y="134" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#C26D3F">TOL</text><text x="36" y="134" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Tolerance</text><rect x="14" y="140" width="252" height="4" rx="2" ry="2" fill="#1e242e"/><text x="14" y="160" font-family=""JetBrains Mono", "JetBrains Mono Variable", ui-monospace, monospace" font-size="10" font-weight="700" fill="#C26D3F">DEN</text><text x="36" y="160" font-family=""Inter", "Inter Variable", system-ui, sans-serif" font-size="12" font-weight="400" fill="#e6e8ec">Density</text><rect x="14" y="166" width="252" height="4" rx="2" ry="2" fill="#1e242e"/></svg>"`;
|
package/test/base64url.test.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { bytesToBase64Url, base64UrlToBytes } from "../src/payload/base64url.ts";
|
|
3
|
-
import { InvalidPayloadError } from "../src/errors.ts";
|
|
4
|
-
|
|
5
|
-
test("round-trips arbitrary bytes", () => {
|
|
6
|
-
const inputs = [
|
|
7
|
-
new Uint8Array([0]),
|
|
8
|
-
new Uint8Array([255]),
|
|
9
|
-
new Uint8Array([0, 1, 2, 3, 4, 5]),
|
|
10
|
-
new Uint8Array(Array.from({ length: 256 }, (_, i) => i)),
|
|
11
|
-
];
|
|
12
|
-
for (const input of inputs) {
|
|
13
|
-
const encoded = bytesToBase64Url(input);
|
|
14
|
-
const decoded = base64UrlToBytes(encoded);
|
|
15
|
-
expect(decoded).toEqual(input);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("produces only URL-safe characters — no +, /, =", () => {
|
|
20
|
-
const bytes = new Uint8Array(Array.from({ length: 256 }, (_, i) => i));
|
|
21
|
-
const encoded = bytesToBase64Url(bytes);
|
|
22
|
-
expect(encoded).toMatch(/^[A-Za-z0-9_-]+$/);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("rejects malformed base64url with InvalidPayloadError", () => {
|
|
26
|
-
expect(() => base64UrlToBytes("!!!not-base64!!!")).toThrow(InvalidPayloadError);
|
|
27
|
-
expect(() => base64UrlToBytes("has spaces")).toThrow(InvalidPayloadError);
|
|
28
|
-
expect(() => base64UrlToBytes("with+plus/slash")).toThrow(InvalidPayloadError);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("accepts known-good short string", () => {
|
|
32
|
-
expect(base64UrlToBytes("AAA")).toEqual(new Uint8Array([0, 0]));
|
|
33
|
-
});
|
package/test/codec.test.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { encodePayload, decodePayload } from "../src/payload/codec.ts";
|
|
3
|
-
import { InvalidPayloadError } from "../src/errors.ts";
|
|
4
|
-
import { FIXTURES } from "./fixtures/cargo-items.ts";
|
|
5
|
-
|
|
6
|
-
test("round-trips every fixture exactly", () => {
|
|
7
|
-
for (const [name, item] of Object.entries(FIXTURES)) {
|
|
8
|
-
const encoded = encodePayload(item);
|
|
9
|
-
const decoded = decodePayload(encoded);
|
|
10
|
-
expect(decoded.item_id.equals(item.item_id), `${name} item_id`).toBe(true);
|
|
11
|
-
expect(decoded.quantity.equals(item.quantity), `${name} quantity`).toBe(true);
|
|
12
|
-
expect(decoded.stats.equals(item.stats), `${name} stats`).toBe(true);
|
|
13
|
-
expect(decoded.modules.length, `${name} modules length`).toBe(item.modules.length);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("encoded payload is URL-safe", () => {
|
|
18
|
-
for (const item of Object.values(FIXTURES)) {
|
|
19
|
-
const encoded = encodePayload(item);
|
|
20
|
-
expect(encoded).toMatch(/^[A-Za-z0-9_-]+$/);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("decodePayload throws InvalidPayloadError on malformed input", () => {
|
|
25
|
-
expect(() => decodePayload("!!!")).toThrow(InvalidPayloadError);
|
|
26
|
-
expect(() => decodePayload("AAA")).toThrow(InvalidPayloadError);
|
|
27
|
-
expect(() => decodePayload("")).toThrow(InvalidPayloadError);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("payload sizes are within expected ranges", () => {
|
|
31
|
-
expect(encodePayload(FIXTURES.oreT1).length).toBeLessThan(30);
|
|
32
|
-
expect(encodePayload(FIXTURES.shipT1NoModules).length).toBeLessThan(30);
|
|
33
|
-
expect(encodePayload(FIXTURES.shipT1TwoModules).length).toBeLessThan(110);
|
|
34
|
-
});
|
package/test/errors.test.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { InvalidPayloadError, UnknownItemError, RenderError } from "../src/errors.ts";
|
|
3
|
-
|
|
4
|
-
test("InvalidPayloadError preserves the message and is an Error", () => {
|
|
5
|
-
const e = new InvalidPayloadError("bad base64");
|
|
6
|
-
expect(e).toBeInstanceOf(Error);
|
|
7
|
-
expect(e).toBeInstanceOf(InvalidPayloadError);
|
|
8
|
-
expect(e.message).toBe("bad base64");
|
|
9
|
-
expect(e.name).toBe("InvalidPayloadError");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("UnknownItemError carries the item id", () => {
|
|
13
|
-
const e = new UnknownItemError(9999);
|
|
14
|
-
expect(e).toBeInstanceOf(UnknownItemError);
|
|
15
|
-
expect(e.itemId).toBe(9999);
|
|
16
|
-
expect(e.message).toContain("9999");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("RenderError wraps a cause", () => {
|
|
20
|
-
const cause = new Error("inner");
|
|
21
|
-
const e = new RenderError("render failed", { cause });
|
|
22
|
-
expect(e).toBeInstanceOf(RenderError);
|
|
23
|
-
expect(e.cause).toBe(cause);
|
|
24
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { ServerContract } from "@shipload/sdk";
|
|
2
|
-
|
|
3
|
-
export const ITEM_ORE_T1 = 101;
|
|
4
|
-
export const ITEM_GAS_T2 = 302;
|
|
5
|
-
export const ITEM_ENGINE_T1 = 10100;
|
|
6
|
-
export const ITEM_GENERATOR_T1 = 10101;
|
|
7
|
-
export const ITEM_GATHERER_T1 = 10102;
|
|
8
|
-
export const ITEM_LOADER_T1 = 10103;
|
|
9
|
-
export const ITEM_MANUFACTURING_T1 = 10104;
|
|
10
|
-
export const ITEM_STORAGE_T1 = 10105;
|
|
11
|
-
export const ITEM_HAULER_T1 = 10106;
|
|
12
|
-
export const ITEM_SHIP_T1_PACKED = 10201;
|
|
13
|
-
|
|
14
|
-
export const MODULE_ENGINE = 1;
|
|
15
|
-
export const MODULE_GENERATOR = 2;
|
|
16
|
-
|
|
17
|
-
export function cargoOreT1(stats = "0x123456789ABCDEF", quantity = 1) {
|
|
18
|
-
return ServerContract.Types.cargo_item.from({
|
|
19
|
-
item_id: ITEM_ORE_T1,
|
|
20
|
-
quantity,
|
|
21
|
-
stats,
|
|
22
|
-
modules: [],
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function cargoShipT1Packed(opts?: {
|
|
27
|
-
stats?: string;
|
|
28
|
-
engineStats?: string;
|
|
29
|
-
generatorStats?: string;
|
|
30
|
-
onlyEngine?: boolean;
|
|
31
|
-
}) {
|
|
32
|
-
const o = opts ?? {};
|
|
33
|
-
const modules: unknown[] = [];
|
|
34
|
-
modules.push({
|
|
35
|
-
type: MODULE_ENGINE,
|
|
36
|
-
installed: { item_id: ITEM_ENGINE_T1, stats: o.engineStats ?? "0x2A4F6B8C" },
|
|
37
|
-
});
|
|
38
|
-
if (!o.onlyEngine) {
|
|
39
|
-
modules.push({
|
|
40
|
-
type: MODULE_GENERATOR,
|
|
41
|
-
installed: { item_id: ITEM_GENERATOR_T1, stats: o.generatorStats ?? "0x1B2D4F" },
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return ServerContract.Types.cargo_item.from({
|
|
45
|
-
item_id: ITEM_SHIP_T1_PACKED,
|
|
46
|
-
quantity: 1,
|
|
47
|
-
stats: o.stats ?? "0",
|
|
48
|
-
modules,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const ITEM_HULL_PLATES = 10001;
|
|
53
|
-
|
|
54
|
-
export const FIXTURES = {
|
|
55
|
-
oreT1: cargoOreT1("0x123456789ABCDEF"),
|
|
56
|
-
oreT1StackOf50: cargoOreT1("0x123456789ABCDEF", 50),
|
|
57
|
-
oreT1ZeroStats: cargoOreT1("0"),
|
|
58
|
-
gasT2: ServerContract.Types.cargo_item.from({
|
|
59
|
-
item_id: ITEM_GAS_T2,
|
|
60
|
-
quantity: 1,
|
|
61
|
-
stats: "0xDEADBEEF1234",
|
|
62
|
-
modules: [],
|
|
63
|
-
}),
|
|
64
|
-
hullPlates: ServerContract.Types.cargo_item.from({
|
|
65
|
-
item_id: ITEM_HULL_PLATES,
|
|
66
|
-
quantity: 1,
|
|
67
|
-
stats: "0x7FFF",
|
|
68
|
-
modules: [],
|
|
69
|
-
}),
|
|
70
|
-
engineT1: ServerContract.Types.cargo_item.from({
|
|
71
|
-
item_id: ITEM_ENGINE_T1,
|
|
72
|
-
quantity: 1,
|
|
73
|
-
stats: "358800",
|
|
74
|
-
modules: [],
|
|
75
|
-
}),
|
|
76
|
-
generatorT1: ServerContract.Types.cargo_item.from({
|
|
77
|
-
item_id: ITEM_GENERATOR_T1,
|
|
78
|
-
quantity: 1,
|
|
79
|
-
stats: "683908",
|
|
80
|
-
modules: [],
|
|
81
|
-
}),
|
|
82
|
-
gathererT1: ServerContract.Types.cargo_item.from({
|
|
83
|
-
item_id: ITEM_GATHERER_T1,
|
|
84
|
-
quantity: 1,
|
|
85
|
-
stats: "138255128433040",
|
|
86
|
-
modules: [],
|
|
87
|
-
}),
|
|
88
|
-
loaderT1: ServerContract.Types.cargo_item.from({
|
|
89
|
-
item_id: ITEM_LOADER_T1,
|
|
90
|
-
quantity: 1,
|
|
91
|
-
stats: "512750",
|
|
92
|
-
modules: [],
|
|
93
|
-
}),
|
|
94
|
-
crafterT1: ServerContract.Types.cargo_item.from({
|
|
95
|
-
item_id: ITEM_MANUFACTURING_T1,
|
|
96
|
-
quantity: 1,
|
|
97
|
-
stats: "512600",
|
|
98
|
-
modules: [],
|
|
99
|
-
}),
|
|
100
|
-
storageT1: ServerContract.Types.cargo_item.from({
|
|
101
|
-
item_id: ITEM_STORAGE_T1,
|
|
102
|
-
quantity: 1,
|
|
103
|
-
stats: "537605632700",
|
|
104
|
-
modules: [],
|
|
105
|
-
}),
|
|
106
|
-
haulerT1: ServerContract.Types.cargo_item.from({
|
|
107
|
-
item_id: ITEM_HAULER_T1,
|
|
108
|
-
quantity: 1,
|
|
109
|
-
stats: "0x3E8",
|
|
110
|
-
modules: [],
|
|
111
|
-
}),
|
|
112
|
-
shipT1NoModules: ServerContract.Types.cargo_item.from({
|
|
113
|
-
item_id: ITEM_SHIP_T1_PACKED,
|
|
114
|
-
quantity: 1,
|
|
115
|
-
stats: "0",
|
|
116
|
-
modules: [],
|
|
117
|
-
}),
|
|
118
|
-
shipT1TwoModules: cargoShipT1Packed(),
|
|
119
|
-
shipT1OnlyEngine: cargoShipT1Packed({ onlyEngine: true }),
|
|
120
|
-
} as const;
|
|
121
|
-
|
|
122
|
-
export type FixtureName = keyof typeof FIXTURES;
|
package/test/fonts.test.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { embedFontsInSvg } from "../src/fonts/index.ts";
|
|
3
|
-
import { loadFontData } from "../src/fonts/load-bun.ts";
|
|
4
|
-
|
|
5
|
-
test("loadFontData returns all four faces with non-zero bytes", async () => {
|
|
6
|
-
const data = await loadFontData();
|
|
7
|
-
expect(Object.keys(data).sort()).toEqual([
|
|
8
|
-
"inter-400",
|
|
9
|
-
"inter-600",
|
|
10
|
-
"jetbrains-500",
|
|
11
|
-
"orbitron-700",
|
|
12
|
-
]);
|
|
13
|
-
for (const [key, bytes] of Object.entries(data)) {
|
|
14
|
-
expect(bytes.byteLength, `${key} bytes`).toBeGreaterThan(2000);
|
|
15
|
-
expect(bytes.byteLength, `${key} bytes`).toBeLessThan(120_000);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("embedFontsInSvg inlines @font-face blocks", async () => {
|
|
20
|
-
const data = await loadFontData();
|
|
21
|
-
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"></svg>';
|
|
22
|
-
const out = embedFontsInSvg(svg, data);
|
|
23
|
-
expect(out).toContain("@font-face");
|
|
24
|
-
expect(out).toContain('font-family: "Orbitron"');
|
|
25
|
-
expect(out).toContain('font-family: "Inter"');
|
|
26
|
-
expect(out).toContain('font-family: "JetBrains Mono"');
|
|
27
|
-
expect(out).toContain("data:font/woff2;base64,");
|
|
28
|
-
});
|
package/test/links-meta.test.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test";
|
|
2
|
-
import { resolveItem } from "@shipload/sdk";
|
|
3
|
-
import { linkToItemImage, linkToItemPage, linkToItemSocial } from "../src/links.ts";
|
|
4
|
-
import { itemPageMeta } from "../src/meta.ts";
|
|
5
|
-
import { FIXTURES } from "./fixtures/cargo-items.ts";
|
|
6
|
-
|
|
7
|
-
test("linkToItemPage defaults to shiploadgame.com", () => {
|
|
8
|
-
const url = linkToItemPage(FIXTURES.oreT1);
|
|
9
|
-
expect(url).toMatch(/^https:\/\/shiploadgame\.com\/guide\/item\/[A-Za-z0-9_-]+$/);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("linkToItemPage accepts a custom base URL", () => {
|
|
13
|
-
const url = linkToItemPage(FIXTURES.oreT1, "http://localhost:5173");
|
|
14
|
-
expect(url.startsWith("http://localhost:5173/guide/item/")).toBe(true);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("linkToItemImage builds a PNG URL", () => {
|
|
18
|
-
const url = linkToItemImage(FIXTURES.oreT1, "png");
|
|
19
|
-
expect(url).toMatch(/^https:\/\/item\.shiploadgame\.com\/item\/[A-Za-z0-9_-]+\.png$/);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("linkToItemImage builds an SVG URL", () => {
|
|
23
|
-
const url = linkToItemImage(FIXTURES.oreT1, "svg");
|
|
24
|
-
expect(url).toMatch(/\.svg$/);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("linkToItemSocial builds a social card URL", () => {
|
|
28
|
-
const url = linkToItemSocial(FIXTURES.oreT1);
|
|
29
|
-
expect(url).toMatch(/^https:\/\/item\.shiploadgame\.com\/social\/[A-Za-z0-9_-]+\.png$/);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("itemPageMeta produces title, description, and ogImage (social card)", () => {
|
|
33
|
-
const item = FIXTURES.oreT1;
|
|
34
|
-
const resolved = resolveItem(item.item_id, item.stats, item.modules);
|
|
35
|
-
const meta = itemPageMeta(item, resolved);
|
|
36
|
-
expect(meta.title).toContain("Crude Ore");
|
|
37
|
-
expect(meta.description).toContain("T1 Ore");
|
|
38
|
-
expect(meta.description).toMatch(/Strength \d+/);
|
|
39
|
-
expect(meta.description).toMatch(/\d+(\.\d+)? t$/);
|
|
40
|
-
expect(meta.ogImage).toMatch(/^https:\/\/item\.shiploadgame\.com\/social\/[A-Za-z0-9_-]+\.png$/);
|
|
41
|
-
expect(meta.ogImageWidth).toBe(1200);
|
|
42
|
-
expect(meta.ogImageHeight).toBe(630);
|
|
43
|
-
});
|
package/test/pixel.test.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { expect, test } from "bun:test";
|
|
5
|
-
import { Resvg } from "@resvg/resvg-js";
|
|
6
|
-
import pixelmatch from "pixelmatch";
|
|
7
|
-
import { PNG } from "pngjs";
|
|
8
|
-
import { resolveItem } from "@shipload/sdk";
|
|
9
|
-
import { renderItem } from "../src/render.ts";
|
|
10
|
-
import { embedFontsInSvg } from "../src/fonts/index.ts";
|
|
11
|
-
import { loadFontData } from "../src/fonts/load-bun.ts";
|
|
12
|
-
import { FIXTURES } from "./fixtures/cargo-items.ts";
|
|
13
|
-
|
|
14
|
-
const SNAP_DIR = resolve(import.meta.dir, "__image_snapshots__");
|
|
15
|
-
const UPDATE = process.env.UPDATE_IMAGE_SNAPSHOTS === "1";
|
|
16
|
-
|
|
17
|
-
await mkdir(SNAP_DIR, { recursive: true });
|
|
18
|
-
const fontData = await loadFontData();
|
|
19
|
-
|
|
20
|
-
async function renderPng(svg: string): Promise<Buffer> {
|
|
21
|
-
const resvg = new Resvg(svg, {
|
|
22
|
-
font: {
|
|
23
|
-
loadSystemFonts: false,
|
|
24
|
-
fontBuffers: Object.values(fontData).map((b) => Buffer.from(b)),
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
return resvg.render().asPng();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const CASES = [
|
|
31
|
-
{ name: "resource-ore-t1", fixture: FIXTURES.oreT1 },
|
|
32
|
-
{ name: "packed-entity-ship-t1-two-modules", fixture: FIXTURES.shipT1TwoModules },
|
|
33
|
-
{ name: "packed-entity-ship-t1-only-engine", fixture: FIXTURES.shipT1OnlyEngine },
|
|
34
|
-
{ name: "component-hull-plates", fixture: FIXTURES.hullPlates },
|
|
35
|
-
{ name: "module-engine-t1", fixture: FIXTURES.engineT1 },
|
|
36
|
-
{ name: "module-storage-t1", fixture: FIXTURES.storageT1 },
|
|
37
|
-
] as const;
|
|
38
|
-
|
|
39
|
-
for (const c of CASES) {
|
|
40
|
-
test(`pixel golden — ${c.name}`, async () => {
|
|
41
|
-
const resolved = resolveItem(c.fixture.item_id, c.fixture.stats, c.fixture.modules);
|
|
42
|
-
const svg = embedFontsInSvg(renderItem(c.fixture, resolved), fontData);
|
|
43
|
-
const png = await renderPng(svg);
|
|
44
|
-
const goldPath = resolve(SNAP_DIR, `${c.name}.png`);
|
|
45
|
-
|
|
46
|
-
if (UPDATE || !existsSync(goldPath)) {
|
|
47
|
-
await writeFile(goldPath, png);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const actual = PNG.sync.read(png);
|
|
52
|
-
const expected = PNG.sync.read(await readFile(goldPath));
|
|
53
|
-
expect(actual.width).toBe(expected.width);
|
|
54
|
-
expect(actual.height).toBe(expected.height);
|
|
55
|
-
const diff = new PNG({ width: actual.width, height: actual.height });
|
|
56
|
-
const diffCount = pixelmatch(
|
|
57
|
-
actual.data,
|
|
58
|
-
expected.data,
|
|
59
|
-
diff.data,
|
|
60
|
-
actual.width,
|
|
61
|
-
actual.height,
|
|
62
|
-
{ threshold: 0.1 },
|
|
63
|
-
);
|
|
64
|
-
if (diffCount > 10) {
|
|
65
|
-
await writeFile(resolve(SNAP_DIR, `${c.name}.diff.png`), PNG.sync.write(diff));
|
|
66
|
-
}
|
|
67
|
-
expect(diffCount).toBeLessThanOrEqual(10);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test";
|
|
2
|
-
import { categoryIconSvg, categoryIconPath } from "../src/primitives/category-icon.ts";
|
|
3
|
-
|
|
4
|
-
test("categoryIconSvg returns self-contained <svg> for each shape", () => {
|
|
5
|
-
for (const shape of ["hex", "diamond", "star", "circle", "square"] as const) {
|
|
6
|
-
const svg = categoryIconSvg(shape);
|
|
7
|
-
expect(svg.startsWith("<svg ")).toBe(true);
|
|
8
|
-
expect(svg.endsWith("</svg>")).toBe(true);
|
|
9
|
-
expect(svg).toContain("viewBox=");
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test("categoryIconSvg respects size option", () => {
|
|
14
|
-
const svg = categoryIconSvg("hex", { size: 24 });
|
|
15
|
-
expect(svg).toContain('width="24"');
|
|
16
|
-
expect(svg).toContain('height="24"');
|
|
17
|
-
expect(svg).toContain('viewBox="0 0 24 24"');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test("categoryIconSvg respects color option", () => {
|
|
21
|
-
const svg = categoryIconSvg("hex", { color: "#ff0000" });
|
|
22
|
-
expect(svg).toContain("#ff0000");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("categoryIconPath returns inline element at given coordinates without svg wrapper", () => {
|
|
26
|
-
const path = categoryIconPath({ shape: "diamond", cx: 50, cy: 50, size: 20, color: "#00ff00" });
|
|
27
|
-
expect(path.startsWith("<svg")).toBe(false);
|
|
28
|
-
expect(path).toMatch(/^<(polygon|rect|circle)\b/);
|
|
29
|
-
expect(path).toContain("#00ff00");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("hex shape produces a 6-point polygon", () => {
|
|
33
|
-
const path = categoryIconPath({ shape: "hex", cx: 50, cy: 50, size: 40, color: "#fff" });
|
|
34
|
-
expect(path).toContain("<polygon");
|
|
35
|
-
const match = path.match(/points="([^"]+)"/);
|
|
36
|
-
expect(match).not.toBeNull();
|
|
37
|
-
const pointCount = match![1].trim().split(/\s+/).length;
|
|
38
|
-
expect(pointCount).toBe(6);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("star shape produces a 10-vertex polygon", () => {
|
|
42
|
-
const path = categoryIconPath({ shape: "star", cx: 50, cy: 50, size: 40, color: "#fff" });
|
|
43
|
-
const match = path.match(/points="([^"]+)"/);
|
|
44
|
-
expect(match).not.toBeNull();
|
|
45
|
-
const pointCount = match![1].trim().split(/\s+/).length;
|
|
46
|
-
expect(pointCount).toBe(10);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("circle shape produces a <circle> element", () => {
|
|
50
|
-
const path = categoryIconPath({ shape: "circle", cx: 50, cy: 50, size: 40, color: "#abc" });
|
|
51
|
-
expect(path).toMatch(/^<circle\b/);
|
|
52
|
-
expect(path).toContain('cx="50"');
|
|
53
|
-
expect(path).toContain('cy="50"');
|
|
54
|
-
expect(path).toContain('r="20"');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test("square shape produces a <rect> element", () => {
|
|
58
|
-
const path = categoryIconPath({ shape: "square", cx: 50, cy: 50, size: 40, color: "#abc" });
|
|
59
|
-
expect(path).toMatch(/^<rect\b/);
|
|
60
|
-
expect(path).toContain('width="40"');
|
|
61
|
-
expect(path).toContain('height="40"');
|
|
62
|
-
expect(path).toContain('x="30"');
|
|
63
|
-
expect(path).toContain('y="30"');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("strokeWidth renders outline mode: fill=none, stroke=color", () => {
|
|
67
|
-
for (const shape of ["hex", "diamond", "star", "circle", "square"] as const) {
|
|
68
|
-
const path = categoryIconPath({
|
|
69
|
-
shape,
|
|
70
|
-
cx: 50,
|
|
71
|
-
cy: 50,
|
|
72
|
-
size: 40,
|
|
73
|
-
color: "#ff0000",
|
|
74
|
-
strokeWidth: 2,
|
|
75
|
-
});
|
|
76
|
-
expect(path).toContain('fill="none"');
|
|
77
|
-
expect(path).toContain('stroke="#ff0000"');
|
|
78
|
-
expect(path).toContain('stroke-width="2"');
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("fill mode (no strokeWidth) does not produce stroke attributes", () => {
|
|
83
|
-
const path = categoryIconPath({ shape: "hex", cx: 50, cy: 50, size: 40, color: "#ff0000" });
|
|
84
|
-
expect(path).toContain('fill="#ff0000"');
|
|
85
|
-
expect(path).not.toContain("stroke=");
|
|
86
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "bun:test";
|
|
2
|
-
import { compactRow } from "../src/primitives/compact-row.ts";
|
|
3
|
-
|
|
4
|
-
test("compactRow emits left-anchored label and right-anchored value", () => {
|
|
5
|
-
const svg = compactRow({
|
|
6
|
-
x: 14,
|
|
7
|
-
y: 80,
|
|
8
|
-
width: 252,
|
|
9
|
-
label: "Thrust",
|
|
10
|
-
value: "700",
|
|
11
|
-
});
|
|
12
|
-
expect(svg).toContain("<text");
|
|
13
|
-
expect(svg).toContain("Thrust");
|
|
14
|
-
expect(svg).toContain("700");
|
|
15
|
-
expect(svg).toContain('x="14"');
|
|
16
|
-
expect(svg).toContain('x="266"');
|
|
17
|
-
expect(svg).toContain('text-anchor="end"');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test("compactRow applies supplied label and value colors", () => {
|
|
21
|
-
const svg = compactRow({
|
|
22
|
-
x: 14,
|
|
23
|
-
y: 80,
|
|
24
|
-
width: 252,
|
|
25
|
-
label: "Drain",
|
|
26
|
-
value: "50",
|
|
27
|
-
labelColor: "#aabbcc",
|
|
28
|
-
valueColor: "#ddeeff",
|
|
29
|
-
});
|
|
30
|
-
expect(svg).toContain('fill="#aabbcc"');
|
|
31
|
-
expect(svg).toContain('fill="#ddeeff"');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("compactRow escapes HTML entities in label and value", () => {
|
|
35
|
-
const svg = compactRow({
|
|
36
|
-
x: 14,
|
|
37
|
-
y: 80,
|
|
38
|
-
width: 252,
|
|
39
|
-
label: "A & B",
|
|
40
|
-
value: "<5",
|
|
41
|
-
});
|
|
42
|
-
expect(svg).toContain("A & B");
|
|
43
|
-
expect(svg).toContain("<5");
|
|
44
|
-
});
|