diff --git a/src/components/Title.jsx b/src/components/Title.jsx
index 073495e5..585c17cf 100644
--- a/src/components/Title.jsx
+++ b/src/components/Title.jsx
@@ -4,7 +4,7 @@ import { getIndexByKey, strings } from '../helpers';
export default function Title({ state }) {
//loading
- if (!state.indexes || !state.input) return;
+ if (!state.indexes || !state.input) return null;
//build title from strings.title
const parts = [];
diff --git a/src/components/Title.spec.tsx b/src/components/Title.spec.tsx
new file mode 100644
index 00000000..97aa91d4
--- /dev/null
+++ b/src/components/Title.spec.tsx
@@ -0,0 +1,98 @@
+import { screen, render } from '@testing-library/react';
+import Title from './Title';
+
+function assertHeadingAndTitleHas(title: string) {
+ const heading = screen.getByRole('heading', { level: 1 });
+ expect(heading).toHaveTextContent(title);
+ expect(document.title).toStrictEqual(title);
+}
+
+describe('
', () => {
+ it('returns null without indices or input', () => {
+ const { container } = render();
+ expect(container.firstChild).toBeNull();
+ });
+
+ it('works with meeting key', () => {
+ render();
+ assertHeadingAndTitleHas('Meetings');
+ });
+
+ it('works with search mode and search term', () => {
+ render(
+
+ );
+ assertHeadingAndTitleHas('Meetings with ‘foo’');
+ });
+
+ it('works with location mode and search term', () => {
+ render(
+
+ );
+ assertHeadingAndTitleHas('Meetings near ‘foo’');
+ });
+
+ it('works with one key', () => {
+ render(
+
+ );
+ assertHeadingAndTitleHas('foo Meetings');
+ });
+
+ it('works with different keys', () => {
+ render(
+
+ );
+ assertHeadingAndTitleHas('foo Meetings in bar');
+ });
+
+ it('works with more different keys', () => {
+ render(
+
+ );
+ assertHeadingAndTitleHas('foo baz Meetings in bar');
+ });
+
+ it('works with multiple of the same key', () => {
+ render(
+
+ );
+ assertHeadingAndTitleHas('foo + bar Meetings');
+ });
+});