From 2863a49fe2f59552f919632990aba55c6c278c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ivind=20Stensrud?= Date: Thu, 14 Dec 2023 13:46:21 +0100 Subject: [PATCH] :white_check_mark: Test for date og AppHeader --- components/AppHeader/AppHeader.test.tsx | 9 +++++++++ lib/utils/date.test.ts | 27 +++++++++++++++++++++++++ next-env.d.ts | 1 - 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 components/AppHeader/AppHeader.test.tsx create mode 100644 lib/utils/date.test.ts diff --git a/components/AppHeader/AppHeader.test.tsx b/components/AppHeader/AppHeader.test.tsx new file mode 100644 index 00000000..592baa44 --- /dev/null +++ b/components/AppHeader/AppHeader.test.tsx @@ -0,0 +1,9 @@ +import { AppHeader } from 'components/AppHeader/AppHeader'; +import { render, screen } from 'setUpTest'; + +describe('AppHeader', () => { + test('har overskrift på nivå h1', () => { + render(); + expect(screen.getByRole('heading', { level: 1, name: 'Mine arbeidsavklarings­penger' })).toBeVisible(); + }); +}); diff --git a/lib/utils/date.test.ts b/lib/utils/date.test.ts new file mode 100644 index 00000000..c6fa6383 --- /dev/null +++ b/lib/utils/date.test.ts @@ -0,0 +1,27 @@ +import { formatDate, formatFullDate } from 'lib/utils/date'; + +describe('date', () => { + describe('formatFullDate', () => { + test('returnerer tom streng når dato er undefined', () => { + const resultat = formatFullDate(undefined); + expect(resultat).toBe(''); + }); + + test('returnerer dato på format dd.MM.yyyy HH:mm', () => { + const resultat = formatFullDate('2023-08-10T12:32'); + expect(resultat).toBe('10.08.2023 12:32'); + }); + }); + + describe('formatDate', () => { + test('returnerer tom streng når dato er undefined', () => { + const resultat = formatDate(undefined); + expect(resultat).toBe(''); + }); + + test('returnerer format på d. MMMM yyyy', () => { + const resultat = formatDate('2023-08-10T12:32'); + expect(resultat).toBe('10. august 2023'); + }); + }); +}); diff --git a/next-env.d.ts b/next-env.d.ts index fd36f949..4f11a03d 100755 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,5 @@ /// /// -/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information.