forked from pagopa/io-app
-
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.
fix: [IABT-1403,IOAPPCIT-9] Birth date is wrong in fiscal code compon…
…ent (pagopa#4197) * fix birth date in place of CF * fix lint error * update birth date in FiscalCodeComponent * update FiscalCodeComponent * fix date test * fix fiscal code birthday * update fiscal code birthday test Co-authored-by: Cristiano Tofani <[email protected]>
- Loading branch information
1 parent
5e111ac
commit 7662cc4
Showing
10 changed files
with
159 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
preset: "react-native", | ||
transform: { | ||
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js" | ||
}, | ||
transformIgnorePatterns: [ | ||
"node_modules/(?!(jest-)?@react-native|react-native|react-navigation|@react-navigation|react-navigation-redux-helpers|react-native-device-info|native-base|native-base-shoutem-theme|@shoutem/animation|@shoutem/ui|rn-placeholder|jsbarcode|@pagopa/react-native-cie|react-native-share|jail-monkey|@react-native-community/art|@react-native-community/push-notification-ios|@react-native-community/cameraroll|@codler|@react-native-community/datetimepicker|remark|unified|bail|is-plain-obj|trough|vfile|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string|micromark|parse-entities|character-entities|mdast-util-to-markdown|zwitch|longest-streak|io-react-native-zendesk)" | ||
], | ||
moduleNameMapper: { | ||
"\\.svg": "<rootDir>/ts/__mocks__/svgMock.js" | ||
}, | ||
setupFiles: ["./jestSetup.js"], | ||
setupFilesAfterEnv: [ | ||
"@testing-library/jest-native/extend-expect", | ||
"./jestSetupAfterEnv.js" | ||
], | ||
collectCoverage: true | ||
}; |
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
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,48 @@ | ||
import { Locales } from "../../../locales/locales"; | ||
import { setLocale } from "../../i18n"; | ||
import { | ||
formatFiscalCodeBirthdayAsShortFormat, | ||
formatFiscalCodeBirthdayAsAccessibilityReadableFormat | ||
} from "../dates"; | ||
|
||
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | ||
describe("Check fiscal code date", () => { | ||
it("IT", () => { | ||
const timeZone = "Europe/Rome"; | ||
testFiscalCodeByLocale("it", timeZone); | ||
testFiscalCodeByLocale("en", timeZone); | ||
}); | ||
|
||
it("NY", () => { | ||
const timeZone = "America/New_York"; | ||
testFiscalCodeByLocale("it", timeZone); | ||
testFiscalCodeByLocale("en", timeZone); | ||
}); | ||
|
||
it("AU", () => { | ||
const timeZone = "Australia/Sydney"; | ||
testFiscalCodeByLocale("it", timeZone); | ||
testFiscalCodeByLocale("en", timeZone); | ||
}); | ||
|
||
it("CA", () => { | ||
const timeZone = "America/Whitehorse"; | ||
testFiscalCodeByLocale("it", timeZone); | ||
testFiscalCodeByLocale("en", timeZone); | ||
}); | ||
}); | ||
|
||
const testFiscalCodeByLocale = (locale: Locales, timeZone: string) => { | ||
setLocale(locale); | ||
// set environment variable TZ from command line | ||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
expect(timezone).toBe(timeZone); | ||
const testDate = new Date("1977-05-22T00:00:00.000Z"); | ||
const checkDate = formatFiscalCodeBirthdayAsShortFormat(testDate!); | ||
const checkDateForAccessibility = | ||
formatFiscalCodeBirthdayAsAccessibilityReadableFormat(testDate!); | ||
const dayName = locale === "it" ? "domenica" : "Sunday"; | ||
const monthName = locale === "it" ? "maggio" : "May"; | ||
expect(`${dayName} 22 ${monthName} 1977`).toBe(checkDateForAccessibility); | ||
expect("22/05/1977").toBe(checkDate); | ||
}; |
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