1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 09:13:19 +01:00
portfolio/tests/pages.test.tsx
Matthias Kretschmann 447cada700
Migrate to Next.js + TypeScript (#1038)
* next.js + typescript

* more testing

* script updates

* fixes

* favicon generation

* testing

* readme updates

* tweaks

* tweaks

* move tests

* image tweaks

* ci tweaks

* commit next-env.d.ts for ci

* migrations

* fixes

* fixes

* ci tweaks

* new animations

* project preview tweaks

* add codeclimate config

* dark mode refactor, test tweaks

* readme updates

* animation tweaks

* animate in loaded images

* test update

* update humans.txt
2022-11-15 23:14:59 +00:00

51 lines
1.3 KiB
TypeScript

import { act, render } from '@testing-library/react'
import IndexPage, { getStaticProps } from '../src/pages'
import ProjectPage, {
getStaticPaths,
getStaticProps as getStaticPropsProject
} from '../src/pages/[slug]'
import projects from './__fixtures__/projects.json'
import project from './__fixtures__/project.json'
import repos from './__fixtures__/repos.json'
import NotFoundPage from '../src/pages/404'
jest.setTimeout(30000)
describe('pages', () => {
it('IndexPage', async () => {
render(<IndexPage projects={projects} repos={repos} />)
})
it('IndexPage/getStaticProps', async () => {
;(global.fetch as jest.Mock) = jest.fn(() =>
Promise.resolve({
ok: true,
json: () => Promise.resolve(repos)
})
)
const props = await getStaticProps({} as any)
expect(props).toBeDefined()
})
it('ProjectPage', () => {
render(<ProjectPage project={project} projects={projects} />)
})
it('ProjectPage/getStaticPaths', async () => {
const props = await getStaticPaths({} as any)
expect(props).toBeDefined()
})
it('ProjectPage/getStaticProps', async () => {
const props = await getStaticPropsProject({ params: { slug: 'ipixelpad' } })
expect(props).toBeDefined()
})
it('NotFoundPage', async () => {
await act(async () => {
render(<NotFoundPage />)
})
})
})