diff --git a/lib/steamdb/__tests__/scrape.test.ts b/lib/steamdb/__tests__/scrape.test.ts
new file mode 100644
index 0000000..27022c3
--- /dev/null
+++ b/lib/steamdb/__tests__/scrape.test.ts
@@ -0,0 +1,65 @@
+import { describe, it, expect } from "vitest"
+
+describe("SteamDB HTML Parser", () => {
+ it("parses version and build from typical SteamDB HTML", async () => {
+ const { _parseSteamDBHtml } = await import("../scrape")
+ // Version regex: /Last known name[^<]*<[^>]*>([^<]+)\s*
]*>(\d+)/i
+ const html = `
+
+
+
+ | Last known name v1.2.3 |
+ | Build ID | 12345678 |
+
+
+
+ `
+
+ const result = _parseSteamDBHtml(html)
+ expect(result.versionString).toBe("v1.2.3")
+ expect(result.buildId).toBe("12345678")
+ })
+
+ it("returns nulls for unrecognized HTML", async () => {
+ const { _parseSteamDBHtml } = await import("../scrape")
+ const result = _parseSteamDBHtml("Nothing here")
+ expect(result.versionString).toBeNull()
+ expect(result.buildId).toBeNull()
+ })
+
+ it("extracts build ID via buildid attribute even without version string", async () => {
+ const { _parseSteamDBHtml } = await import("../scrape")
+ // Build ID regex fallback: /buildid[^>]*>(\d+)/i
+ // buildid[^>]*>(\d+) — expects digits right after the closing tag
+ const html = `99999`
+ const result = _parseSteamDBHtml(html)
+ expect(result.buildId).toBe("99999")
+ expect(result.versionString).toBeNull()
+ })
+
+ it("extracts build ID via Build ID table row pattern", async () => {
+ const { _parseSteamDBHtml } = await import("../scrape")
+ const html = ` | | Build ID | 55555 |
`
+ const result = _parseSteamDBHtml(html)
+ expect(result.buildId).toBe("55555")
+ expect(result.versionString).toBeNull()
+ })
+
+ it("extracts version from JSON-LD when available", async () => {
+ const { _parseSteamDBHtml } = await import("../scrape")
+ const html = `
+
+
+
+
+
+
+ `
+ const result = _parseSteamDBHtml(html)
+ expect(result.versionString).toBe("2.0.0")
+ expect(result.buildId).toBeNull()
+ })
+})