@@ -60,20 +60,53 @@ describe('no', () => {
6060 expect ( no . validateObosMembershipNumber ( input , options ) ) . toBe ( expected ) ;
6161 } ) ;
6262
63- test ( 'validateNationalIdentityNumber()' , ( ) => {
63+ test ( 'validateNationalIdentityNumber() - validates fødselsnummer ' , ( ) => {
6464 for ( let i = 0 ; i < 1000 ; ++ i ) {
65- expect (
66- no . validateNationalIdentityNumber (
67- navfaker . personIdentifikator . fødselsnummer ( ) ,
68- ) ,
69- ) . toBe ( true ) ;
70- expect (
71- no . validateNationalIdentityNumber (
72- navfaker . personIdentifikator . dnummer ( ) ,
73- ) ,
74- ) . toBe ( true ) ;
65+ const fnr = navfaker . personIdentifikator . fødselsnummer ( ) ;
66+ expect ( no . validateNationalIdentityNumber ( fnr ) , `${ fnr } is valid` ) . toBe (
67+ true ,
68+ ) ;
7569 }
7670 } ) ;
71+
72+ test ( 'validateNationalIdentityNumber() - validates d-nummer' , ( ) => {
73+ for ( let i = 0 ; i < 1000 ; ++ i ) {
74+ const dnr = navfaker . personIdentifikator . dnummer ( ) ;
75+ expect ( no . validateNationalIdentityNumber ( dnr ) , `${ dnr } is valid` ) . toBe (
76+ true ,
77+ ) ;
78+ }
79+ } ) ;
80+
81+ test ( 'validateNationalIdentityNumber() - validates leap years' , ( ) => {
82+ expect ( no . validateNationalIdentityNumber ( '29029648784' ) ) . toBe ( true ) ;
83+ } ) ;
84+
85+ test ( 'validateNationalIdentityNumber() - validates 00 as a leap year' , ( ) => {
86+ expect ( no . validateNationalIdentityNumber ( '29020075838' ) ) . toBe ( true ) ;
87+ } ) ;
88+
89+ test ( 'validateNationalIdentityNumber() - returns false for invalid identity numbers' , ( ) => {
90+ expect (
91+ no . validateNationalIdentityNumber ( '13097248032' ) ,
92+ '1st control digit is invalid' ,
93+ ) . toBe ( false ) ;
94+
95+ expect (
96+ no . validateNationalIdentityNumber ( '13097248023' ) ,
97+ '2nd control digit is invalid' ,
98+ ) . toBe ( false ) ;
99+
100+ expect (
101+ no . validateNationalIdentityNumber ( '32127248022' ) ,
102+ 'day is invalid' ,
103+ ) . toBe ( false ) ;
104+
105+ expect (
106+ no . validateNationalIdentityNumber ( '13137248022' ) ,
107+ 'month is invalid' ,
108+ ) . toBe ( false ) ;
109+ } ) ;
77110} ) ;
78111
79112describe ( 'se' , ( ) => {
0 commit comments