Skip to content

Commit

Permalink
✅ Test for date og AppHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
steoiv committed Dec 14, 2023
1 parent 214ecca commit 2863a49
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
9 changes: 9 additions & 0 deletions components/AppHeader/AppHeader.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { AppHeader } from 'components/AppHeader/AppHeader';
import { render, screen } from 'setUpTest';

describe('AppHeader', () => {
test('har overskrift på nivå h1', () => {
render(<AppHeader />);
expect(screen.getByRole('heading', { level: 1, name: 'Mine arbeidsavklarings­penger' })).toBeVisible();
});
});
27 changes: 27 additions & 0 deletions lib/utils/date.test.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
});
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

0 comments on commit 2863a49

Please sign in to comment.