Download this file
| 1 | // presses.test.mjs — the browser's presses against the server's, through |
| 2 | // the shared vectors (vectors/presses.json, which |
| 3 | // internal/slides/deck/presses_test.go reads too). |
| 4 | import { test } from 'node:test' |
| 5 | import assert from 'node:assert/strict' |
| 6 | import { readFileSync } from 'node:fs' |
| 7 | import { presses } from './presses.mjs' |
| 8 | |
| 9 | const vectors = JSON.parse(readFileSync(new URL('./vectors/presses.json', import.meta.url))) |
| 10 | |
| 11 | test('presses vectors', async t => { |
| 12 | assert.ok(vectors.length >= 10) |
| 13 | for (const c of vectors) { |
| 14 | await t.test(c.name, () => { |
| 15 | assert.deepEqual(presses(c.slide, c.scenes), c.presses) |
| 16 | }) |
| 17 | } |
| 18 | }) |
| 19 | |
| 20 | test('a slide with no blocks key has no presses', () => { |
| 21 | assert.deepEqual(presses({ id: 's' }), []) |
| 22 | }) |
| 23 | |