fix(tests): put locale tests behind flag lock

This commit is contained in:
Erica Marigold 2023-09-11 18:02:19 +05:30 committed by GitHub
parent d3dd11313f
commit fcb2057115
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,12 +8,6 @@ assert(
"invalid ISO 8601 formatting for DateTime.formatTime() (UTC)"
)
assert(
DateTime.fromUnixTimestamp(1693068988):formatTime("utc", "%A, %d %B %Y", "fr")
== "samedi, 26 août 2023",
"expected format specifier '%A, %d %B %Y' to return 'samedi, 26 août 2023' for locale 'fr' (UTC)"
)
local expectedTimeString = os.date("%Y-%m-%dT%H:%M:%SZ", 1694078954)
assert(
@ -34,6 +28,21 @@ assert(
"invalid ISO 8601 formatting for DateTime.formatTime() (local)"
)
-- To run tests related to locales, one must explicitly
-- provide the `--test-locales` flag
local toTestLocales = false
for _, arg in process.args do
if arg == "--test-locales" then
toTestLocales = true
break
end
end
if not toTestLocales then
return true
end
local expectedLocalizedString
local dateCmd = process.spawn("bash", { "-c", "date +\"%A, %d %B %Y\" --date='@1693068988'" }, {
@ -53,3 +62,9 @@ assert(
== expectedLocalizedString,
`expected format specifier '%A, %d %B %Y' to return '{expectedLocalizedString}' for locale 'fr' (local)`
)
assert(
DateTime.fromUnixTimestamp(1693068988):formatTime("utc", "%A, %d %B %Y", "fr")
== "samedi, 26 août 2023",
"expected format specifier '%A, %d %B %Y' to return 'samedi, 26 août 2023' for locale 'fr' (UTC)"
)