Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.1
20.19.5
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `@lumx/react`:
- Import types and constants from `@lumx/core` and re-export
- Import `className` utilities from `@lumx/core`
- Migrate tests to `vitest`

## [3.19.0][] - 2025-11-07

Expand Down
1 change: 0 additions & 1 deletion packages/lumx-react/jest/.gitignore

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion packages/lumx-react/jest/__mocks__/emptyModuleMock.js

This file was deleted.

12 changes: 0 additions & 12 deletions packages/lumx-react/jest/configure.js

This file was deleted.

35 changes: 0 additions & 35 deletions packages/lumx-react/jest/index.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lumx-react/jest/transform.js

This file was deleted.

12 changes: 5 additions & 7 deletions packages/lumx-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,26 @@
"@storybook/addon-a11y": "^9.1.4",
"@storybook/addon-docs": "^9.1.4",
"@storybook/react-vite": "^9.1.4",
"@testing-library/dom": "^9.3.4",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^14.4.3",
"@types/body-scroll-lock": "^2.6.1",
"@types/classnames": "^2.2.9",
"@types/dom-view-transitions": "^1.0.5",
"@types/jest": "^29.2.1",
"@types/lodash": "^4.14.149",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.2",
"@types/react-is": "^17.0.2",
"@vitest/ui": "^1.0.0",
"autoprefixer": "^9.7.4",
"babel-jest": "29.1.2",
"babel-loader": "^8.0.6",
"chromatic": "^13.1.4",
"core-js": "^3.6.4",
"focus-visible": "^5.0.2",
"glob": "^7.1.6",
"install-peers-cli": "^2.2.0",
"is-ci": "^2.0.0",
"jest": "29.1.2",
"jest-environment-jsdom": "29.1.2",
"jsdom": "^27.2.0",
"node-notifier": "^10.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand All @@ -70,6 +67,7 @@
"typescript": "^5.4.3",
"vite": "^6.3.5",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^1.0.0",
"yargs": "^15.4.1"
},
"peerDependencies": {
Expand Down Expand Up @@ -100,7 +98,7 @@
"scripts": {
"build": "rollup -c",
"prepare": "install-peers || exit 0",
"test": "jest --config jest/index.js --coverage --notify --passWithNoTests --detectOpenHandles --runInBand",
"test": "vitest run",
"start:storybook": "storybook dev -p 9000",
"build:storybook": "storybook build"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import React from 'react';
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
import { queryByClassName } from '@lumx/react/testing/utils/queries';
import { render } from '@testing-library/react';
import { vi } from 'vitest';
import { AlertDialog, AlertDialogProps } from './AlertDialog';

jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));

const CLASSNAME = AlertDialog.className as string;

Expand All @@ -17,7 +18,7 @@ const setup = (propsOverride: Partial<AlertDialogProps> = {}) => {
title: 'Alert',
isOpen: true,
description: 'Deserunt et sunt qui consequat sint sit.',
confirmProps: { onClick: jest.fn(), label: 'OK' },
confirmProps: { onClick: vi.fn(), label: 'OK' },
...propsOverride,
};
render(<AlertDialog {...props} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe(`<${Autocomplete.displayName}>`, () => {
describe('Events', () => {
it('should trigger the onChange callback when there is a change on the Text Field', async () => {
const name = 'autocomplete-name';
const onChange = jest.fn();
const onChange = vi.fn();
const { inputNative } = setup({
name,
onChange,
Expand All @@ -68,8 +68,8 @@ describe(`<${Autocomplete.displayName}>`, () => {
});

it('should trigger the onFocus/onBlur callback when the text field is focused and blurred', async () => {
const onFocus = jest.fn();
const onBlur = jest.fn();
const onFocus = vi.fn();
const onBlur = vi.fn();
const { inputNative } = setup({
onFocus,
onBlur,
Expand Down
8 changes: 4 additions & 4 deletions packages/lumx-react/src/components/button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ describe(`<${Button.displayName}>`, () => {

describe('Disabled state', () => {
it('should render disabled button', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { button } = setup({ children: 'Label', disabled: true, onClick });
expect(button).toHaveAttribute('disabled');
await userEvent.click(button);
expect(onClick).not.toHaveBeenCalled();
});

it('should render disabled link', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { button } = setup({ children: 'Label', disabled: true, href: 'https://example.com', onClick });
// Disabled link do not exist so we fallback to a button
expect(screen.queryByRole('link')).not.toBeInTheDocument();
Expand All @@ -86,15 +86,15 @@ describe(`<${Button.displayName}>`, () => {
});

it('should render aria-disabled button', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { button } = setup({ children: 'Label', 'aria-disabled': true, onClick });
expect(button).toHaveAttribute('aria-disabled');
await userEvent.click(button);
expect(onClick).not.toHaveBeenCalled();
});

it('should render aria-disabled link', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { button } = setup({
children: 'Label',
'aria-disabled': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe(`<${Checkbox.displayName}>`, () => {
});

describe('Events', () => {
const onChange = jest.fn();
const onChange = vi.fn();

it('should trigger `onChange` when checkbox is clicked', async () => {
const value = 'value';
Expand All @@ -114,7 +114,7 @@ describe(`<${Checkbox.displayName}>`, () => {

describe('Disabled state', () => {
it('should be disabled with isDisabled', async () => {
const onChange = jest.fn();
const onChange = vi.fn();
const { checkbox, input } = setup({ isDisabled: true, onChange });

expect(checkbox).toHaveClass('lumx-checkbox--is-disabled');
Expand All @@ -126,7 +126,7 @@ describe(`<${Checkbox.displayName}>`, () => {
});

it('should be disabled with aria-disabled', async () => {
const onChange = jest.fn();
const onChange = vi.fn();
const { checkbox, input } = setup({ 'aria-disabled': true, onChange });

expect(checkbox).toHaveClass('lumx-checkbox--is-disabled');
Expand Down
36 changes: 19 additions & 17 deletions packages/lumx-react/src/components/chip/Chip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('<Chip />', () => {
});

it('should render clickable', () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { chip } = setup({ children: 'Chip text', onClick });
expect(chip).toHaveAttribute('role', 'button');
expect(chip.className).toMatchInlineSnapshot(
Expand Down Expand Up @@ -70,11 +70,13 @@ describe('<Chip />', () => {
});

describe('Events', () => {
const onClick = jest.fn();
const onAfterClick = jest.fn();
const onBeforeClick = jest.fn();
const onClick = vi.fn();
const onAfterClick = vi.fn();
const onBeforeClick = vi.fn();

beforeEach(jest.clearAllMocks);
beforeEach(() => {
vi.clearAllMocks();
});

it('should trigger onBeforeClick only when clicking on the "before" element', async () => {
const { after, before, chip } = setup({
Expand All @@ -88,12 +90,12 @@ describe('<Chip />', () => {
await userEvent.click(chip);
expect(onBeforeClick).not.toHaveBeenCalled();

jest.clearAllMocks();
vi.clearAllMocks();

await userEvent.click(after as any);
expect(onBeforeClick).not.toHaveBeenCalled();

jest.clearAllMocks();
vi.clearAllMocks();

await userEvent.click(before as any);
expect(onBeforeClick).toHaveBeenCalled();
Expand All @@ -111,12 +113,12 @@ describe('<Chip />', () => {
await userEvent.click(chip);
expect(onClick).toHaveBeenCalled();

jest.clearAllMocks();
vi.clearAllMocks();

await userEvent.click(after as any);
expect(onClick).not.toHaveBeenCalled();

jest.clearAllMocks();
vi.clearAllMocks();

await userEvent.click(before as any);
expect(onClick).not.toHaveBeenCalled();
Expand All @@ -134,12 +136,12 @@ describe('<Chip />', () => {
await userEvent.click(chip);
expect(onAfterClick).not.toHaveBeenCalled();

jest.clearAllMocks();
vi.clearAllMocks();

await userEvent.click(after as any);
expect(onAfterClick).toHaveBeenCalled();

jest.clearAllMocks();
vi.clearAllMocks();

await userEvent.click(before as any);
expect(onAfterClick).not.toHaveBeenCalled();
Expand All @@ -162,7 +164,7 @@ describe('<Chip />', () => {
});

it('should forward key down event', async () => {
const onKeyDown = jest.fn();
const onKeyDown = vi.fn();
const { chip } = setup({ onClick, onKeyDown });

fireEvent.keyDown(chip, { key: 'A', code: 'KeyA' });
Expand All @@ -171,7 +173,7 @@ describe('<Chip />', () => {

it('should forward key down event and trigger `onClick` when pressing Enter', async () => {
const user = userEvent.setup();
const onKeyDown = jest.fn();
const onKeyDown = vi.fn();
const { chip } = setup({ onClick, onKeyDown });

await user.tab();
Expand All @@ -187,15 +189,15 @@ describe('<Chip />', () => {

describe('Disabled state', () => {
it('should render disabled chip button', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { chip } = setup({ children: 'Label', isDisabled: true, onClick });
expect(chip).toHaveAttribute('aria-disabled', 'true');
await userEvent.click(chip);
expect(onClick).not.toHaveBeenCalled();
});

it('should render disabled chip link', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { chip } = setup({ children: 'Label', isDisabled: true, href: 'https://example.com', onClick });
// Disabled link should not have an href.
expect(chip).not.toHaveAttribute('href');
Expand All @@ -205,7 +207,7 @@ describe('<Chip />', () => {
});

it('should render aria-disabled chip button', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { chip } = setup({ children: 'Label', 'aria-disabled': true, onClick });
expect(chip).toHaveAttribute('aria-disabled', 'true');
await userEvent.click(chip);
Expand All @@ -214,7 +216,7 @@ describe('<Chip />', () => {
});

it('should render aria-disabled chip link', async () => {
const onClick = jest.fn();
const onClick = vi.fn();
const { chip } = setup({
children: 'Label',
'aria-disabled': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { DatePicker } from '.';
import { CLASSNAME } from './constants';

const mockedDate = new Date(1487721600000);
Date.now = jest.fn(() => mockedDate.valueOf());
jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
Date.now = vi.fn(() => mockedDate.valueOf());
vi.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
getYearDisplayName: () => 'année',
}));

const setup = (propsOverride: Partial<DatePickerProps> = {}) => {
const props: DatePickerProps = {
locale: 'fr',
onChange: jest.fn(),
onChange: vi.fn(),
value: mockedDate,
nextButtonProps: { label: 'Next month' },
previousButtonProps: { label: 'Previous month' },
Expand Down
Loading
Loading