Skip to content

Commit

Permalink
feat(Tests): added example tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wialy committed Feb 4, 2021
1 parent 5ece7e1 commit e960c15
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/components/rocket-launcher/__tests__/Rocket.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<Rocket />);

const rocket = result.getByText('🚀');

expect(rocket).to.exist;

userEvent.click(rocket);

const fire = screen.getByText('🔥');

expect(fire).to.exist;
});
});
17 changes: 17 additions & 0 deletions src/components/rocket-launcher/__tests__/useRocket.test.tsx
Original file line number Diff line number Diff line change
@@ -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;
});
});

0 comments on commit e960c15

Please sign in to comment.