jevstrudel.git / test / examples.test.mjs
1import { queryCode } from './runtime.mjs';
2import { describe, it } from 'vitest';
3import doc from '../doc.json';
4
5const skippedExamples = [
6  'absoluteOrientationGamma',
7  'absoluteOrientationBeta',
8  'absoluteOrientationAlpha',
9  'orientationGamma',
10  'orientationBeta',
11  'orientationAlpha',
12  'rotationGamma',
13  'rotationBeta',
14  'rotationAlpha',
15  'gravityZ',
16  'gravityY',
17  'gravityX',
18  'accelerationZ',
19  'accelerationY',
20  'accelerationX',
21  'defaultmidimap',
22  'midimaps',
23  'clearScope',
24  'bmod',
25];
26
27describe('runs examples', () => {
28  const { docs } = doc;
29  docs.forEach(async (doc) => {
30    // jev's examples need a Jev; website/src/jev/reference.test.mjs plays them against a stand-in
31    if (skippedExamples.includes(doc.name) || doc.tags?.includes?.('jev')) {
32      return;
33    }
34    doc.examples?.forEach((example, i) => {
35      it(`example "${doc.name}" example index ${i}`, async ({ expect }) => {
36        const haps = await queryCode(example, 4);
37        expect(haps).toMatchSnapshot();
38      });
39    });
40  });
41});