import { I18nProvider } from '@/lib/i18n'; import { renderInClientDom } from '@/test-utils/react-dom'; import assert from 'node:assert/strict'; import { after, before, describe, it } from 'node:test'; type PasswordDialogComponent = typeof import('./password-dialog').PasswordDialog; let PasswordDialog: PasswordDialogComponent; let sharedView: Awaited>; let ownerDocument: Document; before(async () => { sharedView = await renderInClientDom(
); ownerDocument = sharedView.container.ownerDocument; ({ PasswordDialog } = await import('./password-dialog')); }); after(async () => { await sharedView?.cleanup(); }); describe('PasswordDialog', { concurrency: false }, () => { it('associates the access-code input and save action with a native form', async () => { await sharedView.render( {}} onSave={() => {}} description='Configure the access code for this test.' /> ); const input = ownerDocument.querySelector('#password-input'); const form = ownerDocument.querySelector('form'); const saveButton = [...ownerDocument.querySelectorAll('button')].find( (button) => button.textContent === '保存' ); assert.ok(input, 'missing access code input'); assert.ok(form, 'missing access code form'); assert.ok(saveButton, 'missing save button'); assert.equal(input.form, form); assert.equal(saveButton.type, 'submit'); }); });