Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
fix metrics tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tharaldyo committed Aug 15, 2023
1 parent 912bb10 commit 7587afa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion jest/commonMswTestHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { iaTjenesterMetrikkerApiUrl } from '../src/metrikker/iatjenester';
export const commonTestHandlers = [
// Mock suksessfult kall til IA-metrikker
rest.post(iaTjenesterMetrikkerApiUrl, async (_, res, ctx) => {
return res(ctx.json({ status: 'created' }));
return res(ctx.status(201), ctx.json({ status: 'created' }));
}),

rest.post('https://amplitude.nav.no/collect-auto', async (req, res, ctx) => {
Expand Down
7 changes: 3 additions & 4 deletions src/metrikker/iatjenester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ describe('Tester vellykket utsendelse av ia-metrikk', () => {
const nyttOrgnr = '99999999';
const leverteIaTjenester = await sendIaTjenesteMetrikkMottatt(nyttOrgnr);

expect(leverteIaTjenester).toEqual([{ orgnr: '' }, { orgnr: '99999999' }]);
expect(leverteIaTjenester).toEqual([{ orgnr: '99999999' }]);
});

test('skal ikke sende levert ia-tjeneste to ganger for samme virksomhet', async () => {
const nyttOrgnr = '888888882';
await sendIaTjenesteMetrikkMottatt(nyttOrgnr);
const leverteIaTjenester = await sendIaTjenesteMetrikkMottatt(nyttOrgnr);

expect(leverteIaTjenester).toEqual([{ orgnr: '' }, { orgnr: '888888882' }]);
expect(leverteIaTjenester).toEqual([{ orgnr: '888888882' }]);
});
});

Expand All @@ -32,11 +32,10 @@ describe('Tester feilende utsendelse av IA-metrikk', () => {
const nyttOrgnr = '99999999';

const leverteIaTjenester = await sendIaTjenesteMetrikkMottatt(nyttOrgnr);
expect(leverteIaTjenester).toEqual([{ orgnr: '' }]);
expect(leverteIaTjenester).toEqual([]);
});
});

function resetSendteMetrikker() {
sendteMetrikker.length = 0;
sendteMetrikker.push({ orgnr: '' });
}

0 comments on commit 7587afa

Please sign in to comment.