From 485d34caf7428b3a41455a12edf738936d489406 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Mon, 16 Dec 2024 11:17:58 -0500 Subject: [PATCH] chore: fix test --- bin/prepare-examples.js | 3 +-- packages/spec/test/spec.test.js | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/prepare-examples.js b/bin/prepare-examples.js index ee5e55d3..20135cd4 100644 --- a/bin/prepare-examples.js +++ b/bin/prepare-examples.js @@ -3,6 +3,7 @@ import { basename, extname, join, resolve } from 'node:path'; import { copyFile, readdir, readFile, writeFile } from 'node:fs/promises'; import { parseSpec, astToESM } from '@uwdata/mosaic-spec'; import { parse } from 'yaml'; +import pgk from '../packages/spec/package.json' with { type: "json" }; // This script prepares all Mosaic example specifications // ...AND WILL OVERWRITE EXISTING TEST CASE DATA AND DOCS! @@ -11,8 +12,6 @@ import { parse } from 'yaml'; // - YAML, non-parsed JSON, and ESM code written to /docs/public/specs // - Example Markdown pages written to /docs/examples -import pgk from '../packages/spec/package.json' with { type: "json" }; - const specDir = join('specs', 'yaml'); const esmTestDir = join('specs', 'esm'); const jsonTestDir = join('specs', 'json'); diff --git a/packages/spec/test/spec.test.js b/packages/spec/test/spec.test.js index 4469b64f..eeeda174 100644 --- a/packages/spec/test/spec.test.js +++ b/packages/spec/test/spec.test.js @@ -3,6 +3,7 @@ import Ajv from 'ajv'; import ajvFormats from 'ajv-formats'; import { specs, loadJSON, loadJSONSchema, loadESM } from './load-specs.js'; import { astToESM, parseSpec } from '../src/index.js'; +import pgk from '../package.json' with { type: "json" }; // initialize JSON schema validator const validator = new Ajv({ @@ -31,7 +32,10 @@ for (const [name, spec] of specs) { }); it(`produces json output`, async () => { const ast = parseSpec(spec); - const json = JSON.stringify(ast.toJSON(), 0, 2); + const json = JSON.stringify({ + $schema: `https://idl.uw.edu/mosaic/schema/v${pgk.version}.json`, + ...ast.toJSON() + }, 0, 2); expect(json).toBe(await loadJSON(name)); }); it(`round trips json parsing`, () => {