mirror of
https://github.com/danog/CodiceFiscaleJS.git
synced 2024-11-26 20:14:55 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
8c39175b24
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
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
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codice-fiscale-js",
|
||||
"version": "2.3.7",
|
||||
"version": "2.3.8",
|
||||
"description": "The Italian Tax Code Library for Javascript and Typescript",
|
||||
"main": "dist/codice.fiscale.commonjs2.js",
|
||||
"types": "types/codice-fiscale.d.ts",
|
||||
@ -29,7 +29,8 @@
|
||||
"test": "jest",
|
||||
"fix": "standard --fix",
|
||||
"standard": "standard",
|
||||
"rename": "node utils.js"
|
||||
"rename": "node utils.js",
|
||||
"webpack": "webpack"
|
||||
},
|
||||
"author": "Luca Vandro <lucavandro@gmail.com>",
|
||||
"contributors": [
|
||||
|
@ -35,6 +35,7 @@ class CodiceFiscale {
|
||||
}
|
||||
constructor (data) {
|
||||
if (typeof data === 'string') {
|
||||
data = data.toUpperCase()
|
||||
if (CodiceFiscale.check(data)) {
|
||||
this.code = data
|
||||
this.reverse()
|
||||
@ -157,8 +158,8 @@ class CodiceFiscale {
|
||||
}
|
||||
omocodie () {
|
||||
const results = []
|
||||
let lastOmocode = (this.code = this.code.slice(0, 15))
|
||||
for (let i = this.code.length - 1; i >= 0; i = i - 1) {
|
||||
let lastOmocode = (this.code.slice(0, 15))
|
||||
for (let i = this.code.length - 1; i >= 0; i--) {
|
||||
const char = this.code[i]
|
||||
if (char.match(/\d/) !== null) {
|
||||
lastOmocode = `${lastOmocode.substr(0, i)}${OMOCODIA_TABLE[char]}${lastOmocode.substr(i + 1)}`
|
||||
|
@ -105,7 +105,10 @@ describe('CodiceFiscale.compute', () => {
|
||||
.toBeDefined()
|
||||
})
|
||||
|
||||
|
||||
let invalidCfis = "BLIPTR93MO4A674Q";
|
||||
test('controlla il codice fiscale con una regex', () => {
|
||||
expect(CodiceFiscale.check(invalidCfis)).toEqual(false);
|
||||
});
|
||||
|
||||
|
||||
test("calcola il codice fiscale di persone nate all'estero", () => {
|
||||
@ -444,7 +447,21 @@ describe("La classe Comune", ()=>{
|
||||
})
|
||||
})
|
||||
|
||||
let invalidCfis = "BLIPTR93MO4A674Q";
|
||||
test('check invalid cfis by regex control', () => {
|
||||
expect(CodiceFiscale.check(invalidCfis)).toEqual(false);
|
||||
|
||||
|
||||
describe("Il metodo toString()", ()=>{
|
||||
test("funziona correttamente anche con le omocodie", ()=>{
|
||||
let cf = new CodiceFiscale({
|
||||
name: "Mario",
|
||||
surname: "Rossi",
|
||||
gender: "M",
|
||||
birthday: "1987-02-01",
|
||||
birthplace: "H501"
|
||||
});
|
||||
|
||||
expect(cf.toString()).toBe("RSSMRA87B01H501A");
|
||||
cf.omocodie();
|
||||
expect(cf.toString()).toBe("RSSMRA87B01H501A");
|
||||
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user