diff --git a/src/Components/Properties/Properties.test.tsx b/src/Components/Properties/Properties.test.tsx deleted file mode 100644 index 05949a0..0000000 --- a/src/Components/Properties/Properties.test.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { fireEvent, render, screen } from '@testing-library/react'; -import * as React from 'react'; -import { describe, it, vi } from 'vitest'; -import { Properties } from './Properties'; - -describe.concurrent('Properties', () => { - it('No properties', () => { - render( {}} - />); - - expect(screen.queryByText(/property-/i)).toBeNull(); - }); - - it('Some properties', () => { - const prop = { - id: 'stuff', - parentId: 'parentId', - x: 1, - y: 1 - }; - - const handleChange = vi.fn((key, value) => { - (prop as any)[key] = value; - }); - - const { container, rerender } = render(); - - let propertyId = container.querySelector('#property-id'); - let propertyParentId = container.querySelector('#property-parentId'); - let propertyX = container.querySelector('#property-x'); - let propertyY = container.querySelector('#property-y'); - expect(propertyId).toBeDefined(); - expect((propertyId as HTMLInputElement).value).toBe('stuff'); - expect(propertyParentId).toBeDefined(); - expect((propertyParentId as HTMLInputElement).value).toBe('parentId'); - expect(propertyX).toBeDefined(); - expect((propertyX as HTMLInputElement).value).toBe('1'); - expect(propertyY).toBeDefined(); - expect((propertyY as HTMLInputElement).value).toBe('1'); - - fireEvent.change(propertyId as Element, { target: { value: 'stuffed' } }); - fireEvent.change(propertyParentId as Element, { target: { value: 'parentedId' } }); - fireEvent.change(propertyX as Element, { target: { value: '2' } }); - fireEvent.change(propertyY as Element, { target: { value: '2' } }); - expect(handleChange).toBeCalledTimes(4); - - expect(prop.id).toBe('stuffed'); - expect(prop.parentId).toBe('parentedId'); - expect(prop.x).toBe('2'); - expect(prop.y).toBe('2'); - rerender(); - - - propertyId = container.querySelector('#property-id'); - propertyParentId = container.querySelector('#property-parentId'); - propertyX = container.querySelector('#property-x'); - propertyY = container.querySelector('#property-y'); - expect(propertyId).toBeDefined(); - expect((propertyId as HTMLInputElement).value).toBe('stuffed'); - expect(propertyParentId).toBeDefined(); - expect((propertyParentId as HTMLInputElement).value).toBe('parentedId'); - expect(propertyX).toBeDefined(); - expect((propertyX as HTMLInputElement).value).toBe('2'); - expect(propertyY).toBeDefined(); - expect((propertyY as HTMLInputElement).value).toBe('2'); - }); -}); diff --git a/src/Components/Sidebar/Sidebar.test.tsx b/src/Components/Sidebar/Sidebar.test.tsx index 8f283eb..be836a9 100644 --- a/src/Components/Sidebar/Sidebar.test.tsx +++ b/src/Components/Sidebar/Sidebar.test.tsx @@ -3,8 +3,8 @@ import { describe, test, expect, vi } from 'vitest'; import { findByText, fireEvent, render, screen } from '../../utils/test-utils'; import Sidebar from './Sidebar'; -describe.concurrent('Sidebar', () => { - it('Start default', () => { +describe.concurrent('Sidebar open', () => { + it('Start default', async() => { const handleClick = vi.fn(); render( { expect(handleClick).toHaveBeenCalledTimes(1); }); - it('Start close', () => { + it('Start close', async() => { render( { expect(stuff).toBeNull(); }); - it('With stuff', () => { + it('With stuff', async() => { const Type = 'stuff'; - const handleButtonClick = vi.fn(); + const handleButtonClick = vi.fn((type: string) => { + expect(type).toBe(Type); + }); render(