Skip to content

Commit fad4873

Browse files
author
Erik Rasmussen
committed
Tighten test assertions: after rerender only expect field 'b'
1 parent c7ea834 commit fad4873

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/useField.dynamic-name-869.test.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,17 @@ describe('useField - Dynamic Name (Issue #869)', () => {
4444
rerender(<TestComponent fieldName="b" />)
4545
})
4646

47-
// Verify all renders have name and value in sync
47+
// Verify all renders after name change have name='b' and value='value-b'
4848
const calls = renderSpy.mock.calls
4949

5050
// Ensure Field actually rendered
5151
expect(calls.length).toBeGreaterThan(0)
5252

53-
// All calls should have matching name/value pairs
53+
// After rerender with fieldName="b", ALL calls should be for field 'b'
5454
calls.forEach(call => {
5555
const [name, value] = call
56-
// Field name should only be 'a' or 'b'
57-
expect(name).toMatch(/^(a|b)$/)
58-
if (name === 'a') {
59-
expect(value).toBe('value-a')
60-
} else if (name === 'b') {
61-
expect(value).toBe('value-b')
62-
}
56+
expect(name).toBe('b')
57+
expect(value).toBe('value-b')
6358
})
6459
})
6560

0 commit comments

Comments
 (0)