From 9d3dfd82f8e911efb3b43075081c0df3ddaf594e Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Sat, 10 Jan 2026 11:39:23 -0500 Subject: [PATCH] Add test to validate that all constituents are supported by neaps --- test/validate.test.ts | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/test/validate.test.ts b/test/validate.test.ts index a0f00be24..33cd79ab7 100755 --- a/test/validate.test.ts +++ b/test/validate.test.ts @@ -1,11 +1,12 @@ #!/usr/bin/env node -import { describe, test } from "vitest"; +import { describe, test, expect } from "vitest"; import { readFile } from "fs/promises"; import { join } from "path"; import Ajv2020 from "ajv/dist/2020.js"; import addFormats from "ajv-formats"; import { stations } from "../src/index.js"; +import tidePredictor from "@neaps/tide-predictor"; const ROOT = new URL("..", import.meta.url).pathname; const SCHEMA_PATH = join(ROOT, "schemas", "station.schema.json"); @@ -17,13 +18,26 @@ const validate = ajv.compile(schema); describe("schema", () => { stations.forEach((station) => { - test(`Station ${station.id}`, () => { - const valid = validate(station); - if (!valid) - throw new Error( - ajv.errorsText(validate.errors) + - `\n${JSON.stringify(validate.errors, null, 2)}`, - ); + describe(station.id, () => { + test("is valid", () => { + const valid = validate(station); + if (!valid) + throw new Error( + ajv.errorsText(validate.errors) + + `\n${JSON.stringify(validate.errors, null, 2)}`, + ); + }); + + if (station.harmonic_constituents) { + test("uses constituents supported by neaps", () => { + station.harmonic_constituents.forEach((hc) => { + expect( + tidePredictor.constituents[hc.name], + `Unsupported constituent: ${hc.name}`, + ).toBeDefined(); + }); + }); + } }); }); });