Download this file
| 1 | // presence-view.mjs's one pure piece: format(), the catalog |
| 2 | // interpolation every label (avatar, "+N", the block chip, the |
| 3 | // arrival/departure line) goes through. The rest of the module reads |
| 4 | // getBoundingClientRect and ResizeObserver, which is the browser |
| 5 | // drive's job (internal/slidestest/browser_test.go): two contexts, |
| 6 | // each seeing the other's avatar and outline for real. |
| 7 | import test from 'node:test' |
| 8 | import assert from 'node:assert/strict' |
| 9 | import { format } from './presence-view.mjs' |
| 10 | |
| 11 | test('format: {name} and {n} interpolate; an unknown key is left as text', () => { |
| 12 | assert.equal(format('{name} is on this slide', { name: 'Ana Ruiz' }), 'Ana Ruiz is on this slide') |
| 13 | assert.equal(format('{n} more people on this slide', { n: 2 }), '2 more people on this slide') |
| 14 | assert.equal(format('{who} said hi', { name: 'Ana' }), '{who} said hi') |
| 15 | assert.equal(format('', { name: 'Ana' }), '') |
| 16 | assert.equal(format(undefined, {}), '') |
| 17 | }) |
| 18 | |