fix(editor): plurals, trimmed names, default tab, parent drawing confirmation
This commit is contained in:
1 parent
b42c6ae844
commit
be4f468790
35 files changed
+385
-63
No files matched your search
@@ -47,6 +47,42 @@ describe('TextField', () => {
|
||||
expect(onCommit).toHaveBeenCalledWith('Chevalz')
|
||||
})
|
||||
|
||||
it('trim commits a padded name without its edge spaces', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onCommit = vi.fn()
|
||||
render(
|
||||
<TextField id="f" label="Nom" value="Cheval" onCommit={onCommit} trim />,
|
||||
)
|
||||
await user.type(screen.getByLabelText('Nom'), ' {Enter}')
|
||||
expect(onCommit).not.toHaveBeenCalled()
|
||||
await user.type(screen.getByLabelText('Nom'), 'x ')
|
||||
await user.tab()
|
||||
expect(onCommit).toHaveBeenCalledWith('Chevalx')
|
||||
})
|
||||
|
||||
it('trim: a blank value commits as empty; unmount trims too', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onCommit = vi.fn()
|
||||
const view = render(
|
||||
<TextField id="f" label="Nom" value="" onCommit={onCommit} trim />,
|
||||
)
|
||||
await user.type(screen.getByLabelText('Nom'), ' ')
|
||||
await user.tab()
|
||||
expect(onCommit).not.toHaveBeenCalled()
|
||||
await user.type(screen.getByLabelText('Nom'), ' a ')
|
||||
view.unmount()
|
||||
expect(onCommit).toHaveBeenCalledWith('a')
|
||||
})
|
||||
|
||||
it('without trim a padded description commits unchanged', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onCommit = vi.fn()
|
||||
render(<TextField id="f" label="Texte" value="" onCommit={onCommit} />)
|
||||
await user.type(screen.getByLabelText('Texte'), ' a ')
|
||||
await user.tab()
|
||||
expect(onCommit).toHaveBeenCalledWith(' a ')
|
||||
})
|
||||
|
||||
it('a new committed value replaces what was typed; the refusal shows next to the control', () => {
|
||||
const view = render(
|
||||
<TextField
|
||||
|
||||
Reference in new issue
Block a user