Skip to content

Commit

Permalink
Add test to simulate autofill
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Jan 7, 2025
1 parent 687e13c commit 515ace9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/mui-material/src/TextField/TextField.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,28 @@ describe('<TextField />', () => {
expect(getByRole('textbox')).to.have.attribute('data-testid', 'input-element');
});
});

describe('autofill', () => {
it('should be filled after auto fill event', () => {
function AutoFillComponentTest() {
const [value, setValue] = React.useState('');
return (
<TextField
value={value}
onChange={(event) => setValue(event.target.value)}
label="test"
variant="standard"
slotProps={{
htmlInput: { 'data-testid': 'htmlInput' },
inputLabel: { 'data-testid': 'label' },
}}
/>
);
}

const { getByTestId } = render(<AutoFillComponentTest />);
fireEvent.animationStart(getByTestId('htmlInput'), { animationName: 'mui-auto-fill' });
expect(getByTestId('label').getAttribute('data-shrink')).to.equal('true');
});
});
});

0 comments on commit 515ace9

Please sign in to comment.