mirror of
https://github.com/penpot/penpot.git
synced 2026-11-19 16:40:38 +00:00
* 🐛 Fix Chinese locale for dates and relative times * 🐛 Add missing Hindi and Serbian date locales * 🐛 Reset date locale to English for languages without one --------- Co-authored-by: Eva Marco <eva.marco@kaleidos.net>
49 lines
1.8 KiB
Clojure
49 lines
1.8 KiB
Clojure
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
;;
|
|
;; Copyright (c) KALEIDOS SUBSIDIARY SL
|
|
|
|
(ns common-tests.time-test
|
|
(:require
|
|
#?(:cljs ["date-fns/getDefaultOptions$default" :as dfn-get-default-options])
|
|
[app.common.time :as dt]
|
|
[clojure.test :as t]))
|
|
|
|
(t/deftest compare-time
|
|
(let [dta (dt/inst 10000)
|
|
dtb (dt/inst 20000)]
|
|
(t/is (false? (dt/is-after? dta dtb)))
|
|
(t/is (true? (dt/is-before? dta dtb)))))
|
|
|
|
#?(:cljs
|
|
(t/deftest chinese-date-locales-test
|
|
(t/is (= "zh-CN" (some-> (unchecked-get dt/locales "zh_cn") .-code)))
|
|
(t/is (= "zh-TW" (some-> (unchecked-get dt/locales "zh_hant") .-code)))))
|
|
|
|
#?(:cljs
|
|
(t/deftest hindi-and-serbian-date-locales-test
|
|
(t/is (= "hi" (some-> (unchecked-get dt/locales "hi") .-code)))
|
|
(t/is (= "sr" (some-> (unchecked-get dt/locales "sr") .-code)))))
|
|
|
|
#?(:cljs
|
|
(t/deftest unmapped-locale-resets-date-locale-test
|
|
(dt/set-default-locale "ja")
|
|
(dt/set-default-locale "ha")
|
|
(t/is (= "en-US" (.-code (.-locale (dfn-get-default-options)))))
|
|
(dt/set-default-locale "en")))
|
|
|
|
#?(:clj
|
|
(t/deftest parse-duration-test
|
|
(t/is (dt/duration? (dt/parse-duration "10m")))
|
|
(t/is (= (dt/duration "10m") (dt/parse-duration "10m")))
|
|
(t/is (= (dt/duration "1h") (dt/parse-duration "1h")))
|
|
|
|
;; Invalid values are returned unchanged instead of throwing, so
|
|
;; they fail the `duration?` schema predicate with a clean
|
|
;; validation error downstream.
|
|
(t/is (= "yes" (dt/parse-duration "yes")))
|
|
(t/is (not (dt/duration? (dt/parse-duration "yes"))))
|
|
(t/is (= true (dt/parse-duration true)))
|
|
(t/is (not (dt/duration? (dt/parse-duration true))))))
|