Skip to content

Commit

Permalink
fix: unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tokku5552 committed Oct 24, 2024
1 parent 31ec6f8 commit 23409e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/Header/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { ChakraProvider } from '@chakra-ui/react';
import { render } from '@testing-library/react';
import React from 'react';
import { Header } from '..';

describe('Header', () => {
test('rendering', () => {
const { container } = render(<Header />);
const { container } = render(
<ChakraProvider>
<Header />
</ChakraProvider>
);

expect(container.innerHTML).toMatch('GitHub Language Stats');
});
Expand Down
8 changes: 7 additions & 1 deletion src/components/StatsBody/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { ChakraProvider } from '@chakra-ui/react';
import { render } from '@testing-library/react';
import React from 'react';
import StatsBody from '.';

describe('StatsBody', () => {
test('rendering', () => {
const { container } = render(
<StatsBody currentStats="<p>test</p>" currentTopLanguage="<p>test</p>" />
<ChakraProvider>
<StatsBody
currentStats="<p>test</p>"
currentTopLanguage="<p>test</p>"
/>
</ChakraProvider>
);

expect(container.innerHTML).toMatch('<p>test</p><p>test</p>');
Expand Down
7 changes: 6 additions & 1 deletion src/components/StatsForm/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { ChakraProvider } from '@chakra-ui/react';
import '@testing-library/jest-dom/extend-expect';
import { render, screen } from '@testing-library/react';
import React from 'react';
Expand Down Expand Up @@ -36,7 +37,11 @@ describe('StatsForm', () => {
register: registerMock,
formState: formStateMock,
};
render(<StatsForm {...defaultProps} {...props} />);
render(
<ChakraProvider>
<StatsForm {...defaultProps} {...props} />
</ChakraProvider>
);
};

test('renders StatsForm component', () => {
Expand Down

0 comments on commit 23409e5

Please sign in to comment.