Skip to content
Snippets Groups Projects
Unverified Commit d1ad5194 authored by adam-james's avatar adam-james Committed by GitHub
Browse files

Normalize Formatted strings on \space char. (#33186)

* Normalize Formatted strings on \space char.

Some JVMs use nbsp chars in their formatted strings. I noticed weird test failures that printed the same because of
this and it was confusing. So I propose a simple string replace to normalize on one type of space char only.

* Change use of strings in str/replace to chars to pass the linter
parent 2aaef97c
No related merge requests found
(ns metabase.shared.formatting.time-test
(:require
[clojure.string :as str]
[clojure.test :refer [are deftest]]
[metabase.shared.formatting.time :as time]))
(deftest format-time-test
(are [exp input] (= exp (time/format-time input))
;; some JVMs use non-breaking space (nbsp) in their formatted strings
;; which can cause confusing looking test failures.
;; A string replace normalizes on the ascii space char
(are [exp input] (= exp (str/replace (time/format-time input) \u202f \space))
"1:02 AM" "01:02:03.456+07:00"
"1:02 AM" "01:02"
"10:29 PM" "22:29:59.26816+01:00"
......
......@@ -197,7 +197,7 @@
[locale expected] expected]
(mt/with-user-locale locale
(testing (format "%s %s" (.getCanonicalName (class t)) (pr-str t))
(let [actual (u.date/format-human-readable t)]
(let [actual (str/replace (u.date/format-human-readable t) \u202f \space)]
(if (set? expected)
(is (contains? expected actual))
(is (= expected actual))))))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment