From 241e6b67c1ec962f034c8adcf59ee4fdf9c61135 Mon Sep 17 00:00:00 2001 From: Geovanni Perez <1775792+geoperez@users.noreply.github.com> Date: Thu, 9 Nov 2023 10:36:16 -0600 Subject: [PATCH] More tests --- src/CardLoading/CardLoading.spec.tsx | 10 ++++++++++ src/Menu/Menu.spec.tsx | 17 +++++++++++++++++ src/Table/Table.spec.tsx | 12 ++++++++++-- src/UnoLogo/UnoLogo.spec.tsx | 10 ++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/CardLoading/CardLoading.spec.tsx create mode 100644 src/Menu/Menu.spec.tsx create mode 100644 src/UnoLogo/UnoLogo.spec.tsx diff --git a/src/CardLoading/CardLoading.spec.tsx b/src/CardLoading/CardLoading.spec.tsx new file mode 100644 index 0000000..8e93131 --- /dev/null +++ b/src/CardLoading/CardLoading.spec.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { CardLoading } from './index'; + +describe('CardLoading', () => { + it('renders without crashing', () => { + const { container } = render(); + expect(container.firstChild).toBeInTheDocument(); + }); +}); \ No newline at end of file diff --git a/src/Menu/Menu.spec.tsx b/src/Menu/Menu.spec.tsx new file mode 100644 index 0000000..d3c9991 --- /dev/null +++ b/src/Menu/Menu.spec.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import { render, fireEvent } from '@testing-library/react'; +import { Burger } from './index'; + +describe('Burger', () => { + it('renders without crashing', () => { + const { container } = render( { }} />); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('calls onClick when clicked', () => { + const handleClick = jest.fn(); + const { container } = render(); + fireEvent.click(container.firstChild as Element); + expect(handleClick).toHaveBeenCalledTimes(1); + }); +}); \ No newline at end of file diff --git a/src/Table/Table.spec.tsx b/src/Table/Table.spec.tsx index a8d3769..fb9cddd 100644 --- a/src/Table/Table.spec.tsx +++ b/src/Table/Table.spec.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { getAlignment, renderTableCell, Table, TableCellTypes, TableColumn } from './index'; +import { getAlignment, getColumnSorting, renderTableCell, Table, TableCellTypes, TableColumn } from './index'; import { render } from '@testing-library/react'; import { identity } from 'uno-js'; @@ -30,6 +30,14 @@ describe('getAlignment', () => { }); }); +describe('getColumnSorting', () => { + it('returns 1 when the column is sortable', () => { + const tableColumn: TableColumn[] = [{ label: 'column', sortOrder: 1, sortDirection: 'asc' }]; + expect(getColumnSorting(tableColumn, 0)[0].sortOrder).toBe(1); + expect(getColumnSorting(tableColumn, 0)[0].sortDirection).toBe('desc'); + }); +}); + describe('renderTableCell', () => { it('renders a paragraph when the data type is paragraph', () => { const tableColumn: TableColumn = { label: 'column', dataType: 'paragraph' }; @@ -90,7 +98,7 @@ describe('renderTableCell', () => { describe('Table', () => { const tableColumns: TableColumn[] = [ - { label: 'Column 1', dataType: 'string' }, + { label: 'Column 1', dataType: 'string', sortOrder: 1, sortDirection: 'asc' }, { label: 'Column 2', dataType: 'number' }, { label: 'Column 3', dataType: 'money' }, { label: 'Column 4', dataType: 'date' }, diff --git a/src/UnoLogo/UnoLogo.spec.tsx b/src/UnoLogo/UnoLogo.spec.tsx new file mode 100644 index 0000000..da9d37f --- /dev/null +++ b/src/UnoLogo/UnoLogo.spec.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { UnoLogo } from './index'; + +describe('UnoLogo', () => { + it('renders without crashing', () => { + const { container } = render(); + expect(container.firstChild).toBeInTheDocument(); + }); +}); \ No newline at end of file