-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: readonly text input * chore: update TextArea snapshot * Update packages/react/src/components/TextArea/TextArea.js Co-authored-by: Alison Joseph <[email protected]> * fix: file formatting Co-authored-by: Alison Joseph <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2551cd5
commit 70e2231
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/react/src/components/TextArea/__tests__/TextArea-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import TextArea from '../TextArea'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
describe('TextArea', () => { | ||
describe('behaves as expected - Component API', () => { | ||
it('should respect readOnly prop', () => { | ||
const onChange = jest.fn(); | ||
const onClick = jest.fn(); | ||
render( | ||
<TextArea | ||
id="input-1" | ||
labelText="TextArea label" | ||
onClick={onClick} | ||
onChange={onChange} | ||
readOnly | ||
value="test" | ||
/> | ||
); | ||
|
||
// Click events should fire | ||
userEvent.click(screen.getByRole('textbox')); | ||
expect(onClick).toHaveBeenCalledTimes(1); | ||
|
||
// Change events should *not* fire | ||
userEvent.type(screen.getByRole('textbox'), 'x'); | ||
expect(screen.getByRole('textbox')).not.toHaveValue('x'); | ||
expect(onChange).toHaveBeenCalledTimes(0); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters