From 75f5f456527739982f66a00fe36291ea0f54db46 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 31 Jan 2025 08:40:16 +0100 Subject: [PATCH] fix: bring back examples test + ignore device motion examples --- test/examples.test.mjs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/examples.test.mjs diff --git a/test/examples.test.mjs b/test/examples.test.mjs new file mode 100644 index 00000000..997c1cf3 --- /dev/null +++ b/test/examples.test.mjs @@ -0,0 +1,36 @@ +import { queryCode } from './runtime.mjs'; +import { describe, it } from 'vitest'; +import doc from '../doc.json'; + +const skippedExamples = [ + 'absoluteOrientationGamma', + 'absoluteOrientationBeta', + 'absoluteOrientationAlpha', + 'orientationGamma', + 'orientationBeta', + 'orientationAlpha', + 'rotationGamma', + 'rotationBeta', + 'rotationAlpha', + 'gravityZ', + 'gravityY', + 'gravityX', + 'accelerationZ', + 'accelerationY', + 'accelerationX', +]; + +describe('runs examples', () => { + const { docs } = doc; + docs.forEach(async (doc) => { + if (skippedExamples.includes(doc.name)) { + return; + } + doc.examples?.forEach((example, i) => { + it(`example "${doc.name}" example index ${i}`, async ({ expect }) => { + const haps = await queryCode(example, 4); + expect(haps).toMatchSnapshot(); + }); + }); + }); +});