@@ -2,13 +2,22 @@ import { describe, expect, test } from 'vitest';
22import {
33 formatObosMembershipNumber as formatObosMembershipNumberNo ,
44 formatOrganizationNumber as formatOrganizationNumberNo ,
5+ formatPhoneNumber as formatPhoneNumberNo ,
56} from './no' ;
67import {
78 formatObosMembershipNumber as formatObosMembershipNumberSe ,
89 formatOrganizationNumber as formatOrganizationNumberSe ,
10+ formatPhoneNumber as formatPhoneNumberSe ,
911} from './se' ;
1012
1113describe ( 'no' , ( ) => {
14+ test . each ( [
15+ [ '22865500' , '22 86 55 00' ] ,
16+ [ '80000000' , '800 00 000' ] ,
17+ ] ) ( 'formatPhoneNumber(%s) -> %s' , ( input , expected ) => {
18+ expect ( formatPhoneNumberNo ( input ) ) . toBe ( expected ) ;
19+ } ) ;
20+
1221 test . each ( [
1322 [ '000000000' , '000 000 000' ] ,
1423 [ '000 000 000' , '000 000 000' ] ,
@@ -20,6 +29,31 @@ describe('no', () => {
2029} ) ;
2130
2231describe ( 'se' , ( ) => {
32+ test . each ( [
33+ // mobile phone numbers
34+ [ '0701234567' , '070-123 45 67' ] ,
35+ [ '070 12 345 67' , '070-123 45 67' ] ,
36+ // 2 digit area code
37+ [ '0812345' , '08-123 45' ] ,
38+ [ '08123456' , '08-12 34 56' ] ,
39+ [ '081234567' , '08-123 45 67' ] ,
40+ [ '0812345678' , '08-123 456 78' ] ,
41+ // 3 digit area code
42+ [ '03112345' , '031-123 45' ] ,
43+ [ '031123456' , '031-12 34 56' ] ,
44+ [ '0311234567' , '031-123 45 67' ] ,
45+ [ '03112345678' , '031-123 456 78' ] ,
46+ // 4 digit area code
47+ [ '030312345' , '0303-123 45' ] ,
48+ [ '0303123456' , '0303-12 34 56' ] ,
49+ [ '03031234567' , '0303-123 45 67' ] ,
50+ [ '030312345678' , '0303-123 456 78' ] ,
51+ // invalid, too long a number
52+ [ '0303123456789' , '0303123456789' ] ,
53+ ] ) ( 'formatPhoneNumber(%s) -> %s' , ( input , expected ) => {
54+ expect ( formatPhoneNumberSe ( input ) ) . toBe ( expected ) ;
55+ } ) ;
56+
2357 test . each ( [
2458 [ '0000000000' , '000000-0000' ] ,
2559 [ '000000-0000' , '000000-0000' ] ,
0 commit comments