Skip to content

Commit

Permalink
chore: upgrade testing library (#4954)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmfrancois authored Nov 29, 2023
1 parent ea01ec5 commit 24bcb17
Show file tree
Hide file tree
Showing 233 changed files with 5,728 additions and 5,197 deletions.
11 changes: 11 additions & 0 deletions .changeset/heavy-geckos-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@talend/react-faceted-search': minor
'@talend/design-system': minor
'@talend/react-bootstrap': minor
'@talend/react-components': minor
'@talend/react-containers': minor
'@talend/react-forms': minor
'@talend/react-a11y': minor
---

Remove usage of lib keyCode
5 changes: 5 additions & 0 deletions .changeset/strong-keys-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/scripts-config-jest': major
---

chore: bump testing-library to 6.x
10 changes: 3 additions & 7 deletions fork/react-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"prettier": {
"singleQuote": true
},
"files": [
"CHANGELOG.md",
"lib",
Expand All @@ -46,9 +43,9 @@
"@talend/scripts-core": "^16.3.0",
"@talend/scripts-config-babel": "^13.2.0",
"@talend/scripts-config-react-webpack": "^16.3.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^13.5.0",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
"chai": "^4.3.10",
"chalk": "^2.4.2",
"create-react-class": "^15.7.0",
Expand All @@ -63,7 +60,6 @@
"classnames": "^2.3.2",
"dom-helpers": "^3.4.0",
"invariant": "^2.2.4",
"keycode": "^2.2.1",
"prop-types": "^15.8.1",
"prop-types-extra": "^1.1.1",
"react-overlays": "^0.9.3",
Expand Down
173 changes: 88 additions & 85 deletions fork/react-bootstrap/src/Alert.test.js
Original file line number Diff line number Diff line change
@@ -1,92 +1,95 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import Alert from './Alert';

describe('<Alert>', () => {
it('Should output a alert with message', () => {
// when
render(
<Alert>
<strong>Message</strong>
</Alert>
);

// then
expect(screen.getByRole('alert')).toBeInTheDocument();
expect(screen.getByText('Message')).toBeInTheDocument();
});

it('Should have bsType by default', () => {
// when
render(
<Alert>
<strong>Message</strong>
</Alert>
);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-info');
});

it('Should have dismissable style with onDismiss', () => {
// when
render(
<Alert onDismiss={jest.fn()}>
<strong>Message</strong>
</Alert>
);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-dismissable');
});

it('Should call onDismiss callback on dismiss click', () => {
// given
const onDismiss = jest.fn();
render(
<Alert onDismiss={onDismiss} closeLabel="close">
<strong>Message</strong>
</Alert>
);
expect(onDismiss).not.toBeCalled();

// when
userEvent.click(screen.getByRole('button', { name: 'close' }));

// then
expect(onDismiss).toBeCalled();
});

it('Should have a default bsStyle class', () => {
// when
render(<Alert>Message</Alert>);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-info');
});

it('Should have use bsStyle class', () => {
// when
render(<Alert bsStyle="danger">Message</Alert>);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-danger');
});

describe('Web Accessibility', () => {
it('Should call onDismiss callback when the sr-only dismiss link is activated', () => {
// given
const onDismiss = jest.fn();
render(<Alert onDismiss={onDismiss}>Message</Alert>);
expect(onDismiss).not.toBeCalled();

// when
userEvent.click(screen.getByRole('button', { name: 'Close alert' }));

// then
expect(onDismiss).toBeCalled();
});
});
it('Should output a alert with message', () => {
// when
render(
<Alert>
<strong>Message</strong>
</Alert>,
);

// then
expect(screen.getByRole('alert')).toBeInTheDocument();
expect(screen.getByText('Message')).toBeInTheDocument();
});

it('Should have bsType by default', () => {
// when
render(
<Alert>
<strong>Message</strong>
</Alert>,
);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-info');
});

it('Should have dismissable style with onDismiss', () => {
// when
render(
<Alert onDismiss={jest.fn()}>
<strong>Message</strong>
</Alert>,
);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-dismissable');
});

it('Should call onDismiss callback on dismiss click', async () => {
const user = userEvent.setup();

// given
const onDismiss = jest.fn();
render(
<Alert onDismiss={onDismiss} closeLabel="close">
<strong>Message</strong>
</Alert>,
);
expect(onDismiss).not.toHaveBeenCalled();

// when
await user.click(screen.getByRole('button', { name: 'close' }));

// then
expect(onDismiss).toHaveBeenCalled();
});

it('Should have a default bsStyle class', () => {
// when
render(<Alert>Message</Alert>);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-info');
});

it('Should have use bsStyle class', () => {
// when
render(<Alert bsStyle="danger">Message</Alert>);

// then
expect(screen.getByRole('alert')).toHaveClass('alert-danger');
});

describe('Web Accessibility', () => {
it('Should call onDismiss callback when the sr-only dismiss link is activated', async () => {
const user = userEvent.setup();

// given
const onDismiss = jest.fn();
render(<Alert onDismiss={onDismiss}>Message</Alert>);
expect(onDismiss).not.toHaveBeenCalled();

// when
await user.click(screen.getByRole('button', { name: 'Close alert' }));

// then
expect(onDismiss).toHaveBeenCalled();
});
});
});
Loading

0 comments on commit 24bcb17

Please sign in to comment.