mirror of
https://github.com/danog/CodiceFiscaleJS.git
synced 2024-11-26 20:14:55 +01:00
Fixed issue #37
This commit is contained in:
parent
4ef659187f
commit
a23f104245
2
dist/codice.fiscale.amd.js
vendored
2
dist/codice.fiscale.amd.js
vendored
File diff suppressed because one or more lines are too long
2
dist/codice.fiscale.commonjs2.js
vendored
2
dist/codice.fiscale.commonjs2.js
vendored
File diff suppressed because one or more lines are too long
2
dist/codice.fiscale.umd.js
vendored
2
dist/codice.fiscale.umd.js
vendored
File diff suppressed because one or more lines are too long
2
dist/codice.fiscale.var.js
vendored
2
dist/codice.fiscale.var.js
vendored
File diff suppressed because one or more lines are too long
@ -80,7 +80,19 @@ export class Comune {
|
||||
if (result.length === 1) {
|
||||
return { cc: result[0][0], prov: result[0][1], nome: result[0][2] }
|
||||
} else if (result.length > 1) {
|
||||
throw new Error(`Comune with name of ${nome} is found in more than one province. Please specify the province code`)
|
||||
|
||||
for(let i=0; i < result.length; i++){
|
||||
if (result[i][1]!=result[0][1]){
|
||||
throw new Error(`Comune with name of ${nome} is found in more than one province. Please specify the province code`);
|
||||
}
|
||||
}
|
||||
|
||||
for(let i=0; i < result.length; i++){
|
||||
if (result[i][3]==1){
|
||||
return { cc: result[i][0], prov: result[i][1], nome: result[i][2] }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
searchByNameAndProvince (nome, prov) {
|
||||
|
@ -362,6 +362,37 @@ describe('Calcolo del codice fiscale inverso',()=>{
|
||||
test('funziona con i comuni che hanno cambiato provincia, restituendo la provincia a cui è assegnato attualmente il comune', () => {
|
||||
expect(CodiceFiscale.reverse(maria_rossi_cf2).birthplace).toEqual('VIMERCATE');
|
||||
expect(CodiceFiscale.reverse(maria_rossi_cf2).birthplaceProvincia).toEqual('MB');
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
describe('non rileva anomalie con il comune di Calendasco',()=>{
|
||||
|
||||
test('calcola il codice fiscale', () => {
|
||||
expect(CodiceFiscale.compute({
|
||||
name: 'Mario',
|
||||
surname: 'Rossi',
|
||||
gender: 'M',
|
||||
day: 25,
|
||||
month: 12,
|
||||
year: 1980,
|
||||
birthplace: 'Calendasco'
|
||||
}))
|
||||
.toBe('RSSMRA80T25B405Z')
|
||||
})
|
||||
|
||||
test("e anche il codice fiscale inverso", () => {
|
||||
|
||||
let reverse = CodiceFiscale.reverse('RSSMRA80T25B405Z');
|
||||
expect(reverse.name).toEqual('MRA');
|
||||
expect(reverse.surname).toEqual('RSS');
|
||||
expect(reverse.gender).toEqual('M');
|
||||
expect(reverse.day).toEqual(25);
|
||||
expect(reverse.month).toEqual(12);
|
||||
expect(reverse.year).toEqual(1980);
|
||||
expect(reverse.birthplace).toEqual('CALENDASCO');
|
||||
expect(reverse.birthplaceProvincia).toEqual('PC');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user