Skip to content

Commit

Permalink
Fiks innkrevingskrav mock
Browse files Browse the repository at this point in the history
  • Loading branch information
LudvigHz committed Sep 3, 2024
1 parent 92bd871 commit 425ee95
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/mock/innkrevingskrav.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import faker from 'faker/locale/nb_NO';
import { fakerNB_NO as faker } from '@faker-js/faker';
import { fyllRandomListe } from './utils/mock-utils';
import { Innkrevingskrav } from '../app/innkrevingskrav/Innkrevingskrav';
import dayjs from 'dayjs';
import { backendDatoformat } from '../utils/date-utils';
import navfaker from 'nav-faker';

export const mockInnkrevingsKrav = (kravId: string): Innkrevingskrav => {
const seedNr = kravId
.split('')
.map((c) => c.charCodeAt(0))
.reduce((s, c) => s + c, 0);
faker.seed(seedNr);
navfaker.seed(kravId);

return {
kravgrunnlag: {
datoNaarKravVarBesluttetHosOppdragsgiver: dayjs(faker.date.past(1)).format(backendDatoformat)
datoNaarKravVarBesluttetHosOppdragsgiver: dayjs(faker.date.past({ years: 1 })).format(backendDatoformat)
},
krav: fyllRandomListe<Innkrevingskrav['krav'][0]>(getMockKravLinje, 4)
};
};

const getMockKravLinje = () => {
return {
kravType: navfaker.random.arrayElement(['kravLinje', 'renter']),
kravType: faker.helpers.arrayElement(['kravLinje', 'renter']),
opprinneligBeløp: Number(faker.commerce.price()),
gjenståendeBeløp: Number(faker.commerce.price())
};
Expand Down

0 comments on commit 425ee95

Please sign in to comment.