Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
geoperez committed Nov 9, 2023
1 parent 4056704 commit 241e6b6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/CardLoading/CardLoading.spec.tsx
Original file line number Diff line number Diff line change
@@ -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(<CardLoading />);
expect(container.firstChild).toBeInTheDocument();
});
});
17 changes: 17 additions & 0 deletions src/Menu/Menu.spec.tsx
Original file line number Diff line number Diff line change
@@ -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(<Burger onClick={() => { }} />);
expect(container.firstChild).toBeInTheDocument();
});

it('calls onClick when clicked', () => {
const handleClick = jest.fn();
const { container } = render(<Burger onClick={handleClick} />);
fireEvent.click(container.firstChild as Element);
expect(handleClick).toHaveBeenCalledTimes(1);
});
});
12 changes: 10 additions & 2 deletions src/Table/Table.spec.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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' };
Expand Down Expand Up @@ -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' },
Expand Down
10 changes: 10 additions & 0 deletions src/UnoLogo/UnoLogo.spec.tsx
Original file line number Diff line number Diff line change
@@ -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(<UnoLogo />);
expect(container.firstChild).toBeInTheDocument();
});
});

0 comments on commit 241e6b6

Please sign in to comment.