Fix flakey test (#110154)

This commit is contained in:
Scotty Bollinger 2021-08-26 00:32:13 -05:00 committed by GitHub
parent c43429c13b
commit a50a87955c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,18 +20,6 @@ const value = 'foo';
const props = { label, testSubj, value };
describe('CredentialItem', () => {
const setState = jest.fn();
const useStateMock: any = (initState: any) => [initState, setState];
beforeEach(() => {
jest.spyOn(React, 'useState').mockImplementation(useStateMock);
setState(false);
});
afterEach(() => {
jest.clearAllMocks();
});
it('renders', () => {
const wrapper = shallow(<CredentialItem {...props} />);
@ -52,16 +40,15 @@ describe('CredentialItem', () => {
expect(wrapper.find(EuiCopy)).toHaveLength(0);
});
it.skip('handles credential visible toggle click', () => {
it('handles credential visible toggle click', () => {
const wrapper = shallow(<CredentialItem {...props} hideCopy />);
const button = wrapper.find(EuiButtonIcon).dive().find('button');
button.simulate('click');
expect(setState).toHaveBeenCalled();
expect(wrapper.find(EuiFieldText)).toHaveLength(1);
});
it.skip('handles select all button click', () => {
it('handles select all button click', () => {
const wrapper = shallow(<CredentialItem {...props} hideCopy />);
// Toggle isVisible before EuiFieldText is visible
const button = wrapper.find(EuiButtonIcon).dive().find('button');