Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Alert): Update alert to be based on component width #2942

Merged
merged 10 commits into from
Oct 16, 2024
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
aresnik11 committed Oct 3, 2024
commit 1e3d6501eee5a24f2b7a97d4ecf5790d00aea833
9 changes: 8 additions & 1 deletion packages/gamut/src/Alert/__tests__/Alert.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { setupRtl } from '@codecademy/gamut-tests';
import { fireEvent } from '@testing-library/dom';
import { ReactNode } from 'react';

import { Alert } from '../Alert';

@@ -16,6 +17,10 @@ jest.mock('react-use', () => ({
},
}));

jest.mock('../../Tip/Tooltip', () => ({
ToolTip: ({ children }: { children: ReactNode }) => <>{children}</>,
}));

const renderView = setupRtl(Alert, {
onClose,
children,
@@ -34,7 +39,7 @@ describe('Alert', () => {
expect(onClose).toHaveBeenCalled();
});

it('renders a clickable button', () => {
it('renders a clickable button', () => {
const { view } = renderView({ cta: { onClick, children: 'Click Me!' } });

const cta = view.getByRole('button', { name: 'Click Me!' });
@@ -70,6 +75,8 @@ describe('Alert', () => {
});

it('does not render a clickable button and renders untruncated text when on the xs screen size', () => {
mockUseMeasure.mockReturnValueOnce([jest.fn(), { width: 400 }]);

const { view } = renderView({});

expect(view.queryByRole('button', { name: 'Expand' })).toBeNull();
Loading