diff --git a/src/components/rocket-launcher/__tests__/Rocket.test.tsx b/src/components/rocket-launcher/__tests__/Rocket.test.tsx new file mode 100644 index 0000000..550826f --- /dev/null +++ b/src/components/rocket-launcher/__tests__/Rocket.test.tsx @@ -0,0 +1,24 @@ +import { + render, screen, +} from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { expect } from 'chai'; +import React from 'react'; + +import { Rocket } from '../Rocket'; + +describe('Rocket', () => { + it('renders rocket', () => { + const result = render(); + + const rocket = result.getByText('🚀'); + + expect(rocket).to.exist; + + userEvent.click(rocket); + + const fire = screen.getByText('🔥'); + + expect(fire).to.exist; + }); +}); diff --git a/src/components/rocket-launcher/__tests__/useRocket.test.tsx b/src/components/rocket-launcher/__tests__/useRocket.test.tsx new file mode 100644 index 0000000..f90bb6e --- /dev/null +++ b/src/components/rocket-launcher/__tests__/useRocket.test.tsx @@ -0,0 +1,17 @@ +import { renderHook } from '@testing-library/react-hooks/native'; +import { expect } from 'chai'; +import { act } from 'react-dom/test-utils'; + +import { useRocket } from '../useRocket'; + +describe('useRocket', () => { + it('fires a rocket', () => { + const { result } = renderHook(() => useRocket()); + + expect(result.current.isFired).to.be.false; + + act(() => result.current.fire()); + + expect(result.current.isFired).to.be.true; + }); +});