From 1cce87ed010166b4d1c9824daf52dc5342251a1b Mon Sep 17 00:00:00 2001
From: Xavier Abad <77491413+masterprog-cmd@users.noreply.github.com>
Date: Fri, 27 Sep 2024 10:47:40 +0200
Subject: [PATCH] chore(deps): use testing-library instead of
react-test-renderer
---
package.json | 4 +-
.../button/__test__/Button.test.tsx | 23 +-
.../__snapshots__/Button.test.tsx.snap | 1085 ++++++++++++++---
.../__test__/RadioButton.test.tsx | 9 +-
.../__snapshots__/RadioButton.test.tsx.snap | 436 +++++--
.../spinner/__test__/Spinner.test.tsx | 4 +-
.../__snapshots__/Spinner.test.tsx.snap | 127 +-
.../switch/__test__/Switch.test.tsx | 25 +-
.../__snapshots__/Switch.test.tsx.snap | 792 ++++++++----
yarn.lock | 52 +-
10 files changed, 2025 insertions(+), 532 deletions(-)
diff --git a/package.json b/package.json
index 8bf5fa5..eca52fd 100644
--- a/package.json
+++ b/package.json
@@ -32,9 +32,12 @@
"@storybook/react": "^8.0.4",
"@storybook/react-vite": "^8.0.4",
"@storybook/test": "^8.0.4",
+ "@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.2",
+ "@testing-library/user-event": "^14.5.2",
"@types/react": "^18.2.67",
+ "@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@vitest/coverage-istanbul": "^1.4.0",
@@ -51,7 +54,6 @@
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.12",
"react": "^18.2.0",
- "react-test-renderer": "^18.2.0",
"sass": "^1.72.0",
"storybook": "^8.0.4",
"tailwindcss": "^3.4.1",
diff --git a/src/components/button/__test__/Button.test.tsx b/src/components/button/__test__/Button.test.tsx
index df6a1ab..b1a5b20 100644
--- a/src/components/button/__test__/Button.test.tsx
+++ b/src/components/button/__test__/Button.test.tsx
@@ -2,7 +2,6 @@ import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { Button } from '../Button';
-import renderer from 'react-test-renderer';
describe('Button component', () => {
it('Button onClick should be called correctly', () => {
@@ -14,57 +13,57 @@ describe('Button component', () => {
});
it('Primary button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Secondary button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Ghost button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Destructive button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Primary disabled button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Secondary disabled button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Ghost disabled button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Destructive disabled button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Primary medium button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Primary loading button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
it('Primary submit button should render correctly', () => {
- const button = renderer.create().toJSON();
+ const button = render();
expect(button).toMatchSnapshot();
});
});
diff --git a/src/components/button/__test__/__snapshots__/Button.test.tsx.snap b/src/components/button/__test__/__snapshots__/Button.test.tsx.snap
index bb64263..1407d77 100644
--- a/src/components/button/__test__/__snapshots__/Button.test.tsx.snap
+++ b/src/components/button/__test__/__snapshots__/Button.test.tsx.snap
@@ -1,213 +1,1008 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`Button component > Destructive button should render correctly 1`] = `
-