|
1 | 1 | (ns units-test
|
2 | 2 | (:require
|
3 |
| - [cljs.test :refer-macros [deftest testing is]] |
| 3 | + [cljs.test :refer-macros [deftest testing are]] |
4 | 4 | [renderer.utils.units :as units]))
|
5 | 5 |
|
6 | 6 | (deftest test-unit->key
|
7 | 7 | (testing "convert unit string to keyword"
|
8 |
| - (is (= (units/unit->key "px") :px)) |
9 |
| - (is (= (units/unit->key "Px") :px)))) |
| 8 | + (are [x y] (= x y) |
| 9 | + :px (units/unit->key "px") |
| 10 | + :px (units/unit->key "Px")))) |
10 | 11 |
|
11 | 12 | (deftest test-valid-unit?
|
12 | 13 | (testing "check if unit is valid"
|
13 |
| - (is (= (units/valid-unit? "px") true)) |
14 |
| - (is (= (units/valid-unit? "em") true)) |
15 |
| - (is (= (units/valid-unit? "rem") true)) |
16 |
| - (is (= (units/valid-unit? "foo") false)) |
17 |
| - (is (= (units/valid-unit? "") false)))) |
| 14 | + (are [x y] (= x y) |
| 15 | + true (units/valid-unit? "px") |
| 16 | + true (units/valid-unit? "em") |
| 17 | + true (units/valid-unit? "rem") |
| 18 | + false (units/valid-unit? "foo") |
| 19 | + false (units/valid-unit? "")))) |
18 | 20 |
|
19 | 21 | (deftest test-match-unit
|
20 | 22 | (testing "match unit"
|
21 |
| - (is (= (units/match-unit "5px") "px")) |
22 |
| - ;; TODO: The following case should not work. We need to adjust the regex. |
23 |
| - (is (= (units/match-unit "5 px") "px")) |
24 |
| - (is (= (units/match-unit "5454px") "px")) |
25 |
| - (is (= (units/match-unit "px") "px")) |
26 |
| - (is (= (units/match-unit "0") "")))) |
| 23 | + (are [x y] (= x y) |
| 24 | + "px" (units/match-unit "5px") |
| 25 | + ;; TODO: The following case should not work. We need to adjust the regex. |
| 26 | + "px" (units/match-unit "5 px") |
| 27 | + "px" (units/match-unit "5454px") |
| 28 | + "px" (units/match-unit "px") |
| 29 | + "" (units/match-unit "0")))) |
27 | 30 |
|
28 | 31 | (deftest test-parse-unit
|
29 | 32 | (testing "parse unit"
|
30 |
| - (is (= (units/parse-unit "5px") [5 "px"])) |
31 |
| - (is (= (units/parse-unit " 5px ") [5 "px"])) |
32 |
| - (is (= (units/parse-unit " 5 px ") [5 "px"])) |
33 |
| - (is (= (units/parse-unit "5454px") [5454 "px"])) |
34 |
| - (is (= (units/parse-unit "px") [0 "px"])) |
35 |
| - (is (= (units/parse-unit "0") [0 ""])))) |
| 33 | + (are [x y] (= x y) |
| 34 | + [5 "px"] (units/parse-unit "5px") |
| 35 | + [5 "px"] (units/parse-unit " 5px ") |
| 36 | + [5 "px"] (units/parse-unit " 5 px ") |
| 37 | + [5454 "px"] (units/parse-unit "5454px") |
| 38 | + [0 "px"] (units/parse-unit "px") |
| 39 | + [0 ""] (units/parse-unit "0")))) |
0 commit comments