Skip to content

Commit

Permalink
adding namespaced-key->snake-key
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsbarbosa committed Apr 14, 2024
1 parent e6370b6 commit 8a8daa5
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions test/clj_data_adapter/core_test.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
(ns clj-data-adapter.core-test
(:require [clj-data-adapter.core :refer [camel-cased-key->kebab-key
kebab-key->namespaced-key
kebab-key->snake-str namespaced-key->kebab-key opt snake-key->kebab-key snake-key->kebab-str
snake-str->kebab-key str->uuid transform transform-keys transform-keys-1-depth
transform-values transform-values-1-depth uuid->str
namespaced-key->snake-key]]
kebab-key->snake-str namespaced-key->kebab-key namespaced-key->snake-key opt snake-key->kebab-key
snake-key->kebab-str snake-str->kebab-key str->uuid transform transform-keys
transform-keys-1-depth transform-values transform-values-1-depth uuid->str]]
[clojure.test :refer :all]))

(deftest transform-keys-test
Expand Down Expand Up @@ -52,15 +51,15 @@
[{:test/id 1, :test/name "croissant", :test/unit-grams 200, :test/price 5.40M}
{:test/id 4, :test/price 9.40M}]))))
(testing "converts namespaced keys to snake cased keys"
(is (= {:id 1, :name "croissant", :unit_grams 200, :price 5.40M}
(transform-keys namespaced-key->snake-key {:test/id 1, :test/name "croissant", :test/unit-grams 200, :test/price 5.40M}))))
(is (= {:id 1, :name "croissant", :unit_grams 200, :price 5.40M}
(transform-keys namespaced-key->snake-key {:test/id 1, :test/name "croissant", :test/unit-grams 200, :test/price 5.40M}))))
(testing "converts namespaced keys in a vector to snake cased keys"
(is (= [{:id 1, :name "croissant", :unit_grams 200, :price 5.40M}
{:id 4, :price 9.40M}]
(transform-keys
namespaced-key->snake-key
[{:test/id 1, :test/name "croissant", :test/unit-grams 200, :test/price 5.40M}
{:test/id 4, :test/price 9.40M}]))))
(is (= [{:id 1, :name "croissant", :unit_grams 200, :price 5.40M}
{:id 4, :price 9.40M}]
(transform-keys
namespaced-key->snake-key
[{:test/id 1, :test/name "croissant", :test/unit-grams 200, :test/price 5.40M}
{:test/id 4, :test/price 9.40M}]))))
(testing "converts camel cased keys to kebab cased"
(is (= [{:id 1, :bread-name "croissant", :unit-grams 200, :price 5.40M, :a 1, :my-bread "croissant"}]
(transform-keys
Expand Down

0 comments on commit 8a8daa5

Please sign in to comment.