fix: some date related issues

This commit is contained in:
Junyi Du
2022-10-20 17:55:21 +08:00
committed by Tienson Qin
parent a4ee4c48f8
commit 160793e0d1
7 changed files with 47 additions and 9 deletions

View File

@@ -99,7 +99,7 @@
:old-title "aa?#.bbb.ccc",
:changed-title "aa?#/bbb/ccc"}))
(deftest rename-tests
(deftest rename-tests-l2t
;; z: new title structure; x: old ver title; y: title property (if available)
(are [x y z] (= z (#'conversion-handler/calc-rename-target-impl :legacy :triple-lowbar x y))
"aaBBcc" "aabbcc" nil
@@ -137,6 +137,10 @@
:target "adbcde___aks___sdf",
:old-title "adbcde/aks/sdf",
:changed-title "adbcde/aks/sdf"}
"aaa%2Fbbb%2Fccc" "aaa/bbb/ccc" {:status :informal,
:target "aaa___bbb___ccc",
:old-title "aaa/bbb/ccc",
:changed-title "aaa/bbb/ccc"}
"CON" "CON" {:status :informal,
:target "CON___",
:old-title "CON",

View File

@@ -1,6 +1,7 @@
(ns frontend.format.block-test
(:require [cljs.test :refer [deftest testing are]]
[frontend.format.block :as block]))
[frontend.format.block :as block]
[frontend.date :as date]))
(deftest test-normalize-date
(testing "normalize date values"
@@ -49,3 +50,23 @@
"-%"
"-%")))
(deftest test-normalize-journal-title
(testing "normalize journal titles"
(are [x y] (let [f #(-> % date/normalize-journal-title str)]
(= (f x) y))
"Aug 12th, 2022"
"20220812T000000"
"2022-08-12"
"20220812T000000"
"2022-10"
""
"2022Q4"
""
"2022-08"
"")))