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

Commit

Permalink
Statuskode på respons og tester (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFjellstad authored May 27, 2022
1 parent f2e7e9a commit b94943a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/bulk/Innsending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default (
if (response.status === 401) {
setTokenExpired(true);
return validerteAnsatte;
} else if (response.status === 200) {
} else if (response.status === 200 || response.status === 201) {
return response
.json()
.then((data) =>
Expand Down
70 changes: 69 additions & 1 deletion src/components/bulk/berikAnsatte.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import berikAnsatte from './berikAnsatte';
import {
BackendStatus,
BackendResponseState
BackendResponseState,
SkjemaStatus
} from '../../data/types/sporenstreksTypes';
import { Ansatt } from './Ansatt';

Expand Down Expand Up @@ -478,4 +479,71 @@ describe('berikAnsatte', () => {

expect(berikAnsatte(ansatte, backendResponce)).toEqual(expected);
});

it('should set the status for virksomhetsnummer', () => {
const ansatte: Ansatt[] = [
{
id: 1,
fnr: '1',
fom: 'fom',
tom: 'tom',
status: 1,
oppdatert: 1
},
{
id: 2,
fnr: '2',
fom: 'fom',
tom: 'tom',
status: 2,
oppdatert: 2
},
{
id: 3,
fnr: '3',
fom: 'fom',
tom: 'tom',
status: 3,
oppdatert: 3
}
];

const backendResponce: BackendStatus[] = [
{
status: BackendResponseState.GENERIC_ERROR,
validationErrors: null,
genericMessage: null,
referenceNumber: null
}
];

const expected: Ansatt[] = [
{
fnr: '1',
fom: 'fom',
id: 1,
oppdatert: 1,
status: SkjemaStatus.ERRORBACKEND,
tom: 'tom'
},
{
fnr: '2',
fom: 'fom',
id: 2,
oppdatert: 2,
status: SkjemaStatus.GODKJENT,
tom: 'tom'
},
{
fnr: '3',
fom: 'fom',
id: 3,
oppdatert: 3,
status: SkjemaStatus.VALIDERINGSFEIL,
tom: 'tom'
}
];

expect(berikAnsatte(ansatte, backendResponce)).toEqual(expected);
});
});
6 changes: 3 additions & 3 deletions tests/bulkinnsending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const cookieMock = RequestMock()
.onRequestTo(grunnBeloep)
.respond(grunnBeloepVerdier, 200, mockHeaders)
.onRequestTo(innsendingAPI)
.respond(null, 201, mockHeaders);
.respond([{ status: 'OK', referenceNumber: '10' }], 201, mockHeaders);

fixture`Bulkinnsending`
.page`http://localhost:3000/nettrefusjon/bulk/?bedrift=810007842&TestCafe=running`
Expand Down Expand Up @@ -127,9 +127,9 @@ test('Klikk submit uten data, fjern feilmeldinger en etter en og send inn', asyn
await t
// .debug()
.click(tilDato)
.typeText(tilDato, '01.12.2021')
.typeText(tilDato, '13.12.2021')
.click(fraDato)
.typeText(fraDato, '13.12.2021')
.typeText(fraDato, '01.12.2021')
.pressKey('tab')
.expect(Selector('html').textContent)
.notContains('Det må være en gyldig dato');
Expand Down

0 comments on commit b94943a

Please sign in to comment.