import { test } from 'node:test'; import assert from 'node:assert/strict'; import { collectArgs } from './dispatch.ts'; // A minimal Element stub exposing just getAttribute — enough for collectArgs. const el = (attrs: Record) => ({ getAttribute: (k: string) => (k in attrs ? attrs[k] : null) }) as unknown as Element; test('collectArgs reads data-arg then data-arg2 in order', () => { assert.deepEqual(collectArgs(el({ 'data-arg': 'x', 'data-arg2': 'y' })), ['x', 'y']); }); test('collectArgs stops at the first absent arg slot but keeps a present arg2? no — arg only', () => { assert.deepEqual(collectArgs(el({ 'data-arg': 'only' })), ['only']); }); test('collectArgs returns empty when neither is present', () => { assert.deepEqual(collectArgs(el({})), []); }); test('collectArgs preserves empty-string args (attribute present but blank)', () => { assert.deepEqual(collectArgs(el({ 'data-arg': '', 'data-arg2': 'b' })), ['', 'b']); });