Platform-v2 step 2.3 (APPS_PLATFORM D-15 §9): - tokens.css: --x- prefixed colours (light/dark/system + 5 venue accent themes), spacing, radius, type scale, shadows, motion, z-index; variables only - components.css: .x-* classes only, no element selectors (new rule CS-16) - Button, IconButton, Dialog, Sheet, Toast, PinPad, InfoTip, EmptyState, Spinner, Field/Input/Textarea/Select, Switch (accessible: focus trap and restore, ARIA wiring, 44px targets) - tailwind-preset.js (adds names only); manager uses it + styles.css, the waiter imports tokens.css; existing screens unchanged - dev-only /ui-gallery in the manager; e2e suite tests/e2e/ui.mjs; unit tests for PIN rules and WCAG AA contrast of every token pair, both in run-all Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
24 lines
873 B
JavaScript
24 lines
873 B
JavaScript
import assert from 'node:assert/strict'
|
|
import { test } from 'node:test'
|
|
import { nextPin, pinAction } from '../src/components/pin.js'
|
|
|
|
test('keys map to actions', () => {
|
|
assert.deepEqual(pinAction('7'), { type: 'digit', digit: '7' })
|
|
assert.deepEqual(pinAction('Backspace'), { type: 'backspace' })
|
|
assert.deepEqual(pinAction('Delete'), { type: 'backspace' })
|
|
for (const k of ['a', 'Enter', 'Escape', ' ', '12', '']) assert.equal(pinAction(k), null, k)
|
|
})
|
|
|
|
test('digits stop at the length', () => {
|
|
let v = ''
|
|
for (const k of '123456') v = nextPin(v, pinAction(k), 4)
|
|
assert.equal(v, '1234')
|
|
})
|
|
|
|
test('backspace and clear', () => {
|
|
assert.equal(nextPin('123', { type: 'backspace' }, 4), '12')
|
|
assert.equal(nextPin('', { type: 'backspace' }, 4), '')
|
|
assert.equal(nextPin('123', { type: 'clear' }, 4), '')
|
|
assert.equal(nextPin('12', null, 4), '12')
|
|
})
|