Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Dec 16, 2024
1 parent 68138b1 commit 485d34c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions bin/prepare-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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');
Expand Down
6 changes: 5 additions & 1 deletion packages/spec/test/spec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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`, () => {
Expand Down

0 comments on commit 485d34c

Please sign in to comment.