Skip to content

Commit

Permalink
Fix tets
Browse files Browse the repository at this point in the history
  • Loading branch information
nkhristinin committed Oct 2, 2023
1 parent cf02c47 commit 9d92482
Showing 1 changed file with 1 addition and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { act, render, screen, waitFor } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { RiskScoreEntity } from '../../../../../common/search_strategy';
import { TestProviders } from '../../../../common/mock';

import { RiskScoreEnableButton } from './risk_score_enable_button';
import { installRiskScoreModule } from './utils';

jest.mock('./utils');

describe('RiskScoreEnableButton', () => {
const mockRefetch = jest.fn();
Expand All @@ -40,44 +37,5 @@ describe('RiskScoreEnableButton', () => {
'Enable'
);
});

it('Triggers the right installer', async () => {
render(
<TestProviders>
<RiskScoreEnableButton
refetch={mockRefetch}
riskScoreEntity={riskScoreEntity}
timerange={timerange}
/>
</TestProviders>
);

await act(async () => {
await userEvent.click(screen.getByTestId(`enable_${riskScoreEntity}_risk_score`));
});

expect(installRiskScoreModule).toHaveBeenCalled();
});

it('Update button state while installing', async () => {
render(
<TestProviders>
<RiskScoreEnableButton
refetch={mockRefetch}
riskScoreEntity={riskScoreEntity}
timerange={timerange}
/>
</TestProviders>
);

userEvent.click(screen.getByTestId(`enable_${riskScoreEntity}_risk_score`));

await waitFor(() => {
expect(screen.getByTestId(`enable_${riskScoreEntity}_risk_score`)).toHaveProperty(
'disabled',
true
);
});
});
});
});

0 comments on commit 9d92482

Please sign in to comment.