Skip to content

Commit

Permalink
test: apply zero heading test at TOC components
Browse files Browse the repository at this point in the history
  • Loading branch information
hyesungoh committed Apr 13, 2022
1 parent 4b78cc2 commit dc01313
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import DateAndCategoryLink from './DateAndCategoryLink';
const DATE = '2022-04-14';
const CATEGORY = 'Guide';

describe('blog - component - DateAbdCategoryLink', () => {
describe('blog - component - DateAndCategoryLink', () => {
it('should', () => {
render(<DateAndCategoryLink date={DATE} category={CATEGORY} />);
expect(screen.getByText(CATEGORY)).toBeInTheDocument();
Expand Down
21 changes: 21 additions & 0 deletions apps/blog/src/components/TOC/TOC.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { render, screen } from '@testing-library/react';

import TOC from './TOC';

jest.spyOn(React, 'useRef').mockImplementation(() => ({
current: {
observe: jest.fn(),
disconnect: jest.fn(),
},
}));
jest.spyOn(React, 'useEffect').mockImplementation(f => f());

describe('blog - TOC', () => {
beforeAll(() => {});

it('does not render when zero headings', () => {
render(<TOC />);
expect(screen.queryByText('Contents')).not.toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion apps/blog/src/components/TOC/TOC.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { useRouter } from 'next/router';
import styled from '@emotion/styled';
import { Link, NextUITheme, useTheme } from '@nextui-org/react';
Expand Down

0 comments on commit dc01313

Please sign in to comment.