diff --git a/src/App.test.tsx b/src/App.test.tsx index 2dab327..65e7b30 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -20,8 +20,8 @@ describe('App routing', () => { expect(screen.getByRole('heading', { name: /book an appointment/i })).toBeInTheDocument() }) - it('renders the rules placeholder at /rules', () => { + it('renders the Rules page at /rules', () => { render() - expect(screen.getByTestId('page-rules')).toBeInTheDocument() + expect(screen.getByRole('heading', { name: /salon rules/i })).toBeInTheDocument() }) }) diff --git a/src/App.tsx b/src/App.tsx index 18240fa..61356c9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,7 @@ import { BrowserRouter, MemoryRouter, Routes, Route } from 'react-router-dom' import Layout from './components/Layout' import Shop from './pages/Shop' import Book from './pages/Book' +import Rules from './pages/Rules' interface AppProps { initialEntries?: string[] @@ -14,7 +15,7 @@ function AppRoutes() { } /> } /> } /> - } /> + } /> ) diff --git a/src/pages/Rules.module.css b/src/pages/Rules.module.css new file mode 100644 index 0000000..c22facd --- /dev/null +++ b/src/pages/Rules.module.css @@ -0,0 +1,21 @@ +.page { + padding: var(--space-xl) var(--space-lg); + max-width: 680px; + margin: 0 auto; +} + +.section { + margin-bottom: var(--space-lg); +} + +.section h2 { + color: var(--color-gold); + font-size: 1rem; + text-transform: uppercase; + letter-spacing: 1px; +} + +.cta { + text-align: center; + margin-top: var(--space-xl); +} diff --git a/src/pages/Rules.test.tsx b/src/pages/Rules.test.tsx new file mode 100644 index 0000000..978980c --- /dev/null +++ b/src/pages/Rules.test.tsx @@ -0,0 +1,20 @@ +import { render, screen } from '@testing-library/react' +import { MemoryRouter } from 'react-router-dom' +import { describe, it, expect } from 'vitest' +import Rules from './Rules' +import { rules } from '../data/rules' + +describe('Rules page', () => { + it('renders every rule section title and body', () => { + render() + for (const rule of rules) { + expect(screen.getByText(rule.title)).toBeInTheDocument() + expect(screen.getByText(rule.body)).toBeInTheDocument() + } + }) + + it('links back to booking', () => { + render() + expect(screen.getByRole('link', { name: /book/i })).toHaveAttribute('href', '/book') + }) +}) diff --git a/src/pages/Rules.tsx b/src/pages/Rules.tsx new file mode 100644 index 0000000..991d8be --- /dev/null +++ b/src/pages/Rules.tsx @@ -0,0 +1,24 @@ +import { Link } from 'react-router-dom' +import { rules } from '../data/rules' +import styles from './Rules.module.css' + +function Rules() { + return ( +
+

Salon Rules & Policies

+

Please read through before booking your appointment.

+ {rules.map((rule) => ( +
+

{rule.title}

+

{rule.body}

+
+ ))} +
+

By booking, you agree to these terms.

+ Book Now +
+
+ ) +} + +export default Rules