forked from hutamatr/todolist-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,449 additions
and
140 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
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,31 @@ | ||
import { render, screen, userEventSetup, act } from 'test-utils'; | ||
import CategoryForm from './CategoryForm'; | ||
|
||
describe('Category Form Component', () => { | ||
test('render correctly', () => { | ||
render(<CategoryForm />); | ||
|
||
const categoryNameInputElement = screen.getByRole('textbox', { | ||
name: /category name/i, | ||
}); | ||
const createCategoryButtonElement = screen.getByRole('button', { | ||
name: /create category/i, | ||
}); | ||
const cancelButtonElement = screen.getByRole('button', { name: /cancel/i }); | ||
|
||
expect(categoryNameInputElement).toBeInTheDocument(); | ||
expect(createCategoryButtonElement).toBeInTheDocument(); | ||
expect(cancelButtonElement).toBeInTheDocument(); | ||
}); | ||
|
||
test('input category name correctly', async () => { | ||
const { user } = userEventSetup(<CategoryForm />); | ||
|
||
const categoryNameInputElement = screen.getByRole('textbox', { | ||
name: /category name/i, | ||
}); | ||
|
||
await act(() => user.type(categoryNameInputElement, 'learning')); | ||
expect(categoryNameInputElement).toHaveValue('learning'); | ||
}); | ||
}); |
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,11 @@ | ||
import { render, screen } from 'test-utils'; | ||
import CategoryFormModal from './CategoryFormModal'; | ||
|
||
describe('Category Form Modal Component', () => { | ||
test('not show modal on first render', () => { | ||
render(<CategoryFormModal />); | ||
|
||
const categoryHeadingElement = screen.queryByRole('heading', { level: 1 }); | ||
expect(categoryHeadingElement).not.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,32 @@ | ||
import { render, screen } from 'test-utils'; | ||
|
||
import CategoryItem from './CategoryItem'; | ||
|
||
describe('Category Item Component', () => { | ||
test('render correctly', () => { | ||
render(<CategoryItem name={'category-1'} />); | ||
|
||
const categoryImageElement = screen.getByRole('img', { | ||
name: /category\-img/i, | ||
}); | ||
const categoryNameElement = screen.getByText(/category-1/i); | ||
|
||
expect(categoryImageElement).toBeInTheDocument(); | ||
expect(categoryNameElement).toBeInTheDocument(); | ||
}); | ||
|
||
// test('delete category correctly', async () => { | ||
// const { user } = userEventSetup(<CategoryItem />); | ||
|
||
// const categoryNameElement = await screen.findByText(/rickie/i); | ||
// const deleteButtonElement = await screen.findByRole('button'); | ||
|
||
// await user.click(deleteButtonElement); | ||
|
||
// await waitForElementToBeRemoved(() => { | ||
// screen.queryByText(/rickie/i); | ||
// }); | ||
|
||
// expect(categoryNameElement).not.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,40 @@ | ||
import { render, screen } from 'test-utils'; | ||
|
||
import DashboardFormCategory from './DashboardFormCategory'; | ||
import { categoriesData } from 'mocks/testingData'; | ||
|
||
describe('Dashboard Form Category Component', () => { | ||
test('render category list correctly', async () => { | ||
render(<DashboardFormCategory dataCategories={categoriesData} />); | ||
|
||
const categoriesListElement = await screen.findAllByRole('listitem'); | ||
|
||
expect(categoriesListElement).toHaveLength(5); | ||
}); | ||
|
||
test('if category not added render warning', () => { | ||
render(<DashboardFormCategory isCategoryNotAdded={true} />); | ||
|
||
const categoryNotAddedElement = screen.getByText( | ||
/category must be added!/i | ||
); | ||
|
||
expect(categoryNotAddedElement).toBeInTheDocument(); | ||
}); | ||
|
||
test('render loading', () => { | ||
render(<DashboardFormCategory isLoadingCategories={true} />); | ||
|
||
const loadingElement = screen.getByText(/loading/i); | ||
|
||
expect(loadingElement).toBeInTheDocument(); | ||
}); | ||
|
||
test('render add category button correctly', () => { | ||
render(<DashboardFormCategory />); | ||
|
||
const buttonElement = screen.getByRole('button', { name: /add category/i }); | ||
|
||
expect(buttonElement).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
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,39 @@ | ||
import { render, screen } from 'test-utils'; | ||
|
||
import Home from './Home'; | ||
|
||
describe('Home Component', () => { | ||
test('render username correctly', () => { | ||
render(<Home username={'hutamatr'} />); | ||
|
||
const usernameElement = screen.getByRole('heading', { | ||
name: /hello, hutamatr/i, | ||
}); | ||
const textElement = screen.getByText(/what do you want to do today?/i); | ||
|
||
expect(usernameElement).toBeInTheDocument(); | ||
expect(textElement).toBeInTheDocument(); | ||
}); | ||
|
||
test('render initial total todos correctly', () => { | ||
render(<Home />); | ||
|
||
const totalTodosElement = screen.getByRole('heading', { level: 2 }); | ||
|
||
expect(totalTodosElement).toHaveTextContent(/you have 0 list todo/i); | ||
}); | ||
|
||
test('render image correctly', () => { | ||
render(<Home />); | ||
|
||
const totalTodosImageElement = screen.getByAltText(/todo/i); | ||
const categoryImageElement = screen.getByAltText(/category/i); | ||
const doneImageElement = screen.getByAltText(/done/i); | ||
const inProgressImageElement = screen.getByAltText(/in progress/i); | ||
|
||
expect(totalTodosImageElement).toBeInTheDocument(); | ||
expect(categoryImageElement).toBeInTheDocument(); | ||
expect(doneImageElement).toBeInTheDocument(); | ||
expect(inProgressImageElement).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,15 @@ | ||
import { render, screen } from 'test-utils'; | ||
|
||
import Layout from './Layout'; | ||
|
||
describe('Layout Component', () => { | ||
test('render correctly', () => { | ||
render(<Layout />); | ||
|
||
const headerElement = screen.getByRole('banner'); | ||
const mainElement = screen.getByRole('main'); | ||
|
||
expect(headerElement).toBeInTheDocument(); | ||
expect(mainElement).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
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,21 @@ | ||
import { render, screen } from 'test-utils'; | ||
|
||
import LayoutWithoutNav from './LayoutWithoutNav'; | ||
|
||
describe('Layout Without Nav Component', () => { | ||
test('render correctly', () => { | ||
render(<LayoutWithoutNav />); | ||
|
||
const mainElement = screen.getByRole('main'); | ||
|
||
expect(mainElement).toBeInTheDocument(); | ||
}); | ||
|
||
test('render image correctly', () => { | ||
render(<LayoutWithoutNav />); | ||
|
||
const figureElement = screen.getByRole('figure'); | ||
|
||
expect(figureElement).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
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,30 @@ | ||
import { render, screen } from 'test-utils'; | ||
|
||
import Navigation from './Navigation'; | ||
|
||
describe('Navigation Component', () => { | ||
test('render correctly', () => { | ||
render(<Navigation />); | ||
|
||
const navigationElement = screen.getByRole('navigation'); | ||
const ulElement = screen.getAllByRole('list'); | ||
const liElement = screen.getAllByRole('listitem'); | ||
|
||
const listItems = liElement.map((item) => item.textContent); | ||
|
||
expect(navigationElement).toBeInTheDocument(); | ||
expect(ulElement).toHaveLength(2); | ||
expect(liElement).toHaveLength(7); | ||
expect(listItems).toMatchInlineSnapshot(` | ||
Array [ | ||
"Home", | ||
"Dashboard", | ||
"Category", | ||
"Profile", | ||
"Logout", | ||
"Profile", | ||
"Logout", | ||
] | ||
`); | ||
}); | ||
}); |
Oops, something went wrong.