From 7eb6c8ab06a9d7099fcc1e9b71afa1ee9d99b604 Mon Sep 17 00:00:00 2001 From: beny25585 Date: Thu, 30 Apr 2026 14:31:23 +0300 Subject: [PATCH 1/3] test for the check box --- .gitignore | 1 + .../UI/Checkbox/SGLCeckBox.test.tsx | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/components/UI/Checkbox/SGLCeckBox.test.tsx diff --git a/.gitignore b/.gitignore index a547bf3..9d751f8 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ dist-ssr *.njsproj *.sln *.sw? +.cocoindex_code \ No newline at end of file diff --git a/src/components/UI/Checkbox/SGLCeckBox.test.tsx b/src/components/UI/Checkbox/SGLCeckBox.test.tsx new file mode 100644 index 0000000..f698137 --- /dev/null +++ b/src/components/UI/Checkbox/SGLCeckBox.test.tsx @@ -0,0 +1,48 @@ +import { render, screen, fireEvent } from '@testing-library/react' +import { describe, it, expect, vi } from 'vitest' +import { SGLCheckbox } from './SGLCheckbox' + +describe('SGLCheckbox', () => { + //tests for the checkbox!! + // test 1: + it('should toggle from checked to unchecked', () => { + render() + + const checkbox = screen.getByRole('checkbox') + + fireEvent.click(checkbox) + + expect(checkbox).not.toBeChecked() + }) + // test 2: + it('should toggle from unchecked to checked ', () => { + render() + + const checkbox = screen.getByRole('checkbox') + + fireEvent.click(checkbox) + + expect(checkbox).toBeChecked() + }) + // test 3: + it('should be disabled ', () => { + render() + + const checkbox = screen.getByRole('checkbox') + + expect(checkbox).toBeDisabled() + }) + //test 4: + it('should change on onChange', () => { + const HandleOnChange = vi.fn() + + render() + + const checkbox = screen.getByRole('checkbox') + + expect(checkbox).not.toBeChecked() + fireEvent.click(checkbox) + expect(checkbox).toBeChecked() + expect(HandleOnChange).toHaveBeenCalledTimes(1) + }) +}) From b9beac3d6f4ae1edd9bf6a5e65bd82473cc48ffc Mon Sep 17 00:00:00 2001 From: beny25585 Date: Tue, 26 May 2026 18:45:55 +0300 Subject: [PATCH 2/3] remove comments --- src/components/UI/Checkbox/SGLCeckBox.test.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/UI/Checkbox/SGLCeckBox.test.tsx b/src/components/UI/Checkbox/SGLCeckBox.test.tsx index f698137..2f93f42 100644 --- a/src/components/UI/Checkbox/SGLCeckBox.test.tsx +++ b/src/components/UI/Checkbox/SGLCeckBox.test.tsx @@ -3,8 +3,6 @@ import { describe, it, expect, vi } from 'vitest' import { SGLCheckbox } from './SGLCheckbox' describe('SGLCheckbox', () => { - //tests for the checkbox!! - // test 1: it('should toggle from checked to unchecked', () => { render() @@ -14,7 +12,6 @@ describe('SGLCheckbox', () => { expect(checkbox).not.toBeChecked() }) - // test 2: it('should toggle from unchecked to checked ', () => { render() @@ -24,7 +21,6 @@ describe('SGLCheckbox', () => { expect(checkbox).toBeChecked() }) - // test 3: it('should be disabled ', () => { render() @@ -32,7 +28,6 @@ describe('SGLCheckbox', () => { expect(checkbox).toBeDisabled() }) - //test 4: it('should change on onChange', () => { const HandleOnChange = vi.fn() From 63a63d590426ec37e6eeee67832851302e0c12c8 Mon Sep 17 00:00:00 2001 From: beny25585 Date: Wed, 27 May 2026 20:25:14 +0300 Subject: [PATCH 3/3] camelCase handelOnChange --- src/components/UI/Checkbox/SGLCeckBox.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/UI/Checkbox/SGLCeckBox.test.tsx b/src/components/UI/Checkbox/SGLCeckBox.test.tsx index 2f93f42..a897937 100644 --- a/src/components/UI/Checkbox/SGLCeckBox.test.tsx +++ b/src/components/UI/Checkbox/SGLCeckBox.test.tsx @@ -29,15 +29,15 @@ describe('SGLCheckbox', () => { expect(checkbox).toBeDisabled() }) it('should change on onChange', () => { - const HandleOnChange = vi.fn() + const handleOnChange = vi.fn() - render() + render() const checkbox = screen.getByRole('checkbox') expect(checkbox).not.toBeChecked() fireEvent.click(checkbox) expect(checkbox).toBeChecked() - expect(HandleOnChange).toHaveBeenCalledTimes(1) + expect(handleOnChange).toHaveBeenCalledTimes(1) }) })