From e93d4238db813ed08da1ac9f9b2ba0403356e8cb Mon Sep 17 00:00:00 2001 From: Paulo Amorim Date: Thu, 19 Sep 2024 04:26:57 -0300 Subject: [PATCH 01/11] initial jest configuration --- jest.config.js | 12 + jsapp/js/components/common/button.test.tsx | 61 + package-lock.json | 35377 +++++++++++-------- package.json | 16 +- 4 files changed, 21180 insertions(+), 14286 deletions(-) create mode 100644 jest.config.js create mode 100644 jsapp/js/components/common/button.test.tsx diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000000..a14453643a --- /dev/null +++ b/jest.config.js @@ -0,0 +1,12 @@ +/** @type {import('jest').Config} */ +const config = { + verbose: true, + testEnvironment: 'jsdom', + roots: ['/jsapp'], + moduleNameMapper: { + '^js/(.*)$': '/jsapp/js/$1', + '\\.(css|scss)$': 'identity-obj-proxy', + }, +}; + +module.exports = config; diff --git a/jsapp/js/components/common/button.test.tsx b/jsapp/js/components/common/button.test.tsx new file mode 100644 index 0000000000..efd6c6be68 --- /dev/null +++ b/jsapp/js/components/common/button.test.tsx @@ -0,0 +1,61 @@ +import React from 'react'; +import '@testing-library/jest-dom'; + +import Button from './button'; + +import {render, screen} from '@testing-library/react'; +import {expect, jest} from '@jest/globals'; +import userEvent from '@testing-library/user-event'; + +describe('Button renders', () => { + it('Should render and be clickable when enabled', async () => { + const user = userEvent.setup(); + + // Mock + const handleClickFunction = jest.fn(); + + // Render + render( +