Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Dec 10, 2024
1 parent 1e3499d commit 0d5c506
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
17 changes: 17 additions & 0 deletions apps/public/src/app/(map)/layout.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render } from '@testing-library/react'

import Layout from './layout'

describe('Layout', () => {
it('should render', () => {
const { container } = render(<Layout>Test</Layout>)

const outerWrapper = container.querySelector('html')
const body = container.querySelector('body')
const main = container.querySelector('main')

expect(outerWrapper).toHaveAttribute('lang', 'nl')
expect(body).toBeInTheDocument()
expect(main).toBeInTheDocument()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { render } from '@testing-library/react'

import { BaseLayer } from './BaseLayer'

describe('BaseLayer', () => {
it('renders the component', () => {
const { container } = render(<BaseLayer />)
expect(container.firstChild).toBeInTheDocument()
})
})

// TODO: add tests
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const BaseLayer = () => {
zoomControl: false,
maxZoom: 18,
minZoom: 11,
// Prevent the user browsing too far outside Amsterdam otherwise the map will render blank greyspace. Amsterdam tile layer only supports Amsterdam and the immediate surrounding areas
// Prevent the user browsing too far outside Amsterdam otherwise the map will render blank greyspace.
// Amsterdam tile layer only supports Amsterdam and the immediate surrounding areas
maxBounds: [
[52.25168, 4.64034],
[52.50536, 5.10737],
Expand Down
3 changes: 0 additions & 3 deletions apps/public/src/app/(map)/locatie/kies/_components/Map.tsx

This file was deleted.

15 changes: 15 additions & 0 deletions apps/public/src/app/(map)/locatie/kies/page.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { render, waitFor } from '@testing-library/react'

import Page from './page'

describe('Page', () => {
it('should render', async () => {
const { container } = render(<Page />)

const outerWrapper = container.querySelector('div')

waitFor(() => {
expect(outerWrapper).toBeInTheDocument()
})
})
})
2 changes: 1 addition & 1 deletion apps/public/src/app/(map)/locatie/kies/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import dynamic from 'next/dynamic'

const Map = dynamic(() => import('./_components/Map').then((module) => module.Map), {
const Map = dynamic(() => import('./_components/BaseLayer').then((module) => module.BaseLayer), {
loading: () => <p>Loading...</p>, // TODO: improve loading state
ssr: false,
})
Expand Down

0 comments on commit 0d5c506

Please sign in to comment.