This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tillate 0 dager på enkeltinnsending uten å gjøre det samme på bulk (#380
- Loading branch information
1 parent
df02ed4
commit 1cb2a4d
Showing
8 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/components/dager/validateDagerEnkeltinnsending.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import validateDagerEnkeltinnsending from './validateDagerEnkeltinnsending'; | ||
|
||
describe('validateDagerEnkeltinnsending', () => { | ||
it('should not allow zero', () => { | ||
expect(validateDagerEnkeltinnsending(0)).toEqual( | ||
'Dager må være høyere enn 0' | ||
); | ||
}); | ||
|
||
it('should not accept undefined', () => { | ||
expect(validateDagerEnkeltinnsending()).toBe('Feltet må fylles ut'); | ||
}); | ||
|
||
it('should accept 1-13', () => { | ||
expect(validateDagerEnkeltinnsending(1)).toBeUndefined(); | ||
expect(validateDagerEnkeltinnsending(13)).toBeUndefined(); | ||
}); | ||
|
||
it('should not accept negative', () => { | ||
expect(validateDagerEnkeltinnsending(-1)).toEqual( | ||
'Dager må være høyere enn 0' | ||
); | ||
}); | ||
|
||
it('should not allow to high value', () => { | ||
expect(validateDagerEnkeltinnsending(14)).toEqual( | ||
'Dager må være 13 eller lavere' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const validateDager = (value?: number): string | undefined => { | ||
if (value === undefined) { | ||
return 'Feltet må fylles ut'; | ||
} else if (value <= 0) { | ||
return 'Dager må være høyere enn 0'; | ||
} else if (value > 13) { | ||
return 'Dager må være 13 eller lavere'; | ||
} | ||
return undefined; | ||
}; | ||
|
||
export default validateDager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters