-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: blog error pages (404, 500, offline)) * test: fix typo at blog error pages * test: blog index page * test: blog slug page * test: blog app and document at pages * test: blog category/[category] page
- Loading branch information
Showing
10 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NotFound as CoreNotFount } from 'core'; | ||
|
||
import NotFound from '../404.page'; | ||
|
||
describe('blog - pages - 404', () => { | ||
it('should defined', () => { | ||
expect(NotFound).toBeDefined(); | ||
}); | ||
|
||
it('should return core NotFound component', () => { | ||
expect(NotFound).toBe(CoreNotFount); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ServerError as CoreServerError } from 'core'; | ||
|
||
import ServerError from '../500.page'; | ||
|
||
describe('blog - pages - 500', () => { | ||
it('should defined', () => { | ||
expect(ServerError).toBeDefined(); | ||
}); | ||
|
||
it('should return core ServerError component', () => { | ||
expect(ServerError).toBe(CoreServerError); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import Slug from '../[slug].page'; | ||
|
||
const MOCK_POST = { | ||
slug: 'comet-land', | ||
title: 'Comet-land', | ||
subtitle: 'blog and resume theme', | ||
date: '2022-01-01', | ||
category: 'blog', | ||
content: '<h2>heading</h2>', | ||
ogImage: null, | ||
}; | ||
|
||
// NOTE: prevent ResizeObserver and IntersectionObserver at PageProgressBar, TOC | ||
jest.spyOn(React, 'useEffect').mockImplementation(f => f()); | ||
|
||
describe('blog - pages - [slug]', () => { | ||
it('should defined', () => { | ||
expect(Slug).toBeDefined(); | ||
}); | ||
|
||
it('should render main', () => { | ||
render(<Slug {...MOCK_POST} />); | ||
|
||
expect(screen.getByRole('main')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render one level 1 heading', () => { | ||
render(<Slug {...MOCK_POST} />); | ||
|
||
expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import BlogApp from '../_app.page'; | ||
|
||
describe('blog - pages - app', () => { | ||
it('should defined', () => { | ||
expect(BlogApp).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import BlogDocument from '../_document.page'; | ||
|
||
describe('blog - pages - document', () => { | ||
it('should defined', () => { | ||
expect(BlogDocument).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Offline as CoreOffline } from 'core'; | ||
|
||
import Offline from '../_offline.page'; | ||
|
||
describe('blog - pages - offline', () => { | ||
it('should defined', () => { | ||
expect(Offline).toBeDefined(); | ||
}); | ||
|
||
it('should return core NotFound component', () => { | ||
expect(Offline).toBe(CoreOffline); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import Category from '../../category/[category].page'; | ||
|
||
const MOCK_CATEGORY = 'mockCategory'; | ||
const MOCK_POST = { | ||
slug: 'comet-land', | ||
title: 'Comet-land', | ||
subtitle: 'blog and resume theme', | ||
date: '2022-01-01', | ||
category: 'blog', | ||
content: '<h2>heading</h2>', | ||
}; | ||
|
||
describe('blog - pages - category - [category]', () => { | ||
it('should defined', () => { | ||
expect(Category).toBeDefined(); | ||
}); | ||
|
||
it('should render main', () => { | ||
render(<Category category={MOCK_CATEGORY} allPosts={[MOCK_POST]} />); | ||
|
||
expect(screen.getByRole('main')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render allPosts props', () => { | ||
render(<Category category={MOCK_CATEGORY} allPosts={[MOCK_POST]} />); | ||
|
||
expect(screen.getByText(MOCK_POST.title)).toBeInTheDocument(); | ||
expect(screen.getByText(MOCK_POST.subtitle)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render category at lever 2 heading', () => { | ||
render(<Category category={MOCK_CATEGORY} allPosts={[]} />); | ||
|
||
expect(screen.getAllByRole('heading', { level: 2 }).at(-1)).toHaveTextContent(MOCK_CATEGORY); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import Index from '../index.page'; | ||
|
||
const MOCK_POST = { | ||
slug: 'comet-land', | ||
title: 'Comet-land', | ||
subtitle: 'blog and resume theme', | ||
date: '2022-01-01', | ||
category: 'blog', | ||
content: '<h2>heading</h2>', | ||
}; | ||
|
||
describe('blog - pages - index', () => { | ||
it('should defined', () => { | ||
expect(Index).toBeDefined(); | ||
}); | ||
|
||
it('should render main', () => { | ||
render(<Index allPosts={[MOCK_POST]} />); | ||
|
||
expect(screen.getByRole('main')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render post title', () => { | ||
render(<Index allPosts={[MOCK_POST]} />); | ||
|
||
expect(screen.getByText(MOCK_POST.title)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should has one level 1 heading', () => { | ||
render(<Index allPosts={[MOCK_POST]} />); | ||
|
||
expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument(); | ||
}); | ||
}); |
818f4ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
comet-land-blog – ./apps/blog
comet-land-blog.vercel.app
comet-land-blog-hyesungoh.vercel.app
comet-land-blog-git-main-hyesungoh.vercel.app
818f4ab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
comet-land-resume – ./apps/resume
comet-land-resume.vercel.app
comet-land-resume-hyesungoh.vercel.app
comet-land-resume-git-main-hyesungoh.vercel.app