Skip to content

Commit 7f87a1d

Browse files
committed
enhance tests
1 parent add1f52 commit 7f87a1d

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

test/bounds_test.cljs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
(ns bounds-test
22
(:require
3-
[cljs.test :refer-macros [deftest testing is]]
3+
[cljs.test :refer-macros [deftest testing are is]]
44
[renderer.utils.bounds :as bounds]))
55

66
(deftest test-union
77
(testing "united bounds"
8-
(is (= (bounds/union [0 0 10 10] [11 11 20 20]) [0 0 20 20]))
9-
(is (= (bounds/union [0 0 10 10] [9 9 20 20]) [0 0 20 20]))
10-
(is (= (bounds/union [11 11 11 11] [0 0 0 0]) [0 0 11 11]))))
11-
8+
(are [x y] (= x y)
9+
[0 0 20 20] (bounds/union [0 0 10 10] [11 11 20 20])
10+
[0 0 20 20] (bounds/union [0 0 10 10] [9 9 20 20])
11+
[0 0 11 11] (bounds/union [11 11 11 11] [0 0 0 0]))))
1212

1313
(deftest test-intersect?
1414
(testing "bounds are intesrecting"
15-
(is (= (bounds/intersect? [0 0 10 10] [11 11 20 20]) false))
16-
(is (= (bounds/intersect? [0 0 10 10] [9 9 20 20]) true))
17-
(is (= (bounds/intersect? [0 0 10 10] [10 10 11 11]) true))))
15+
(are [x y] (= x y)
16+
false (bounds/intersect? [0 0 10 10] [11 11 20 20])
17+
true (bounds/intersect? [0 0 10 10] [9 9 20 20])
18+
true (bounds/intersect? [0 0 10 10] [10 10 11 11]))))
1819

1920
(deftest test-contained?
2021
(testing "bounds are contained"
21-
(is (= (bounds/contained? [0 0 10 10] [0 0 10 10]) false))
22-
(is (= (bounds/contained? [5 5 10 10] [0 0 20 20]) true))
23-
(is (= (bounds/contained? [0 0 10 10] [1 1 10 10]) false))))
22+
(are [x y] (= x y)
23+
false (bounds/contained? [0 0 10 10] [0 0 10 10])
24+
true (bounds/contained? [5 5 10 10] [0 0 20 20])
25+
false (bounds/contained? [0 0 10 10] [1 1 10 10]))))
2426

2527
(deftest test-contain-point?
2628
(testing "bounds contain point"
27-
(is (= (bounds/contain-point? [0 0 10 10] [0 0]) true))
28-
(is (= (bounds/contain-point? [0 0 10 10] [5 5]) true))
29-
(is (= (bounds/contain-point? [0 0 10 10] [10 10]) true))
30-
(is (= (bounds/contain-point? [0 0 10 10] [-5 5]) false))
31-
(is (= (bounds/contain-point? [0 0 10 10] [5 -5]) false))))
29+
(are [x y] (= x y)
30+
true (bounds/contain-point? [0 0 10 10] [0 0])
31+
true (bounds/contain-point? [0 0 10 10] [5 5])
32+
true (bounds/contain-point? [0 0 10 10] [10 10])
33+
false (bounds/contain-point? [0 0 10 10] [-5 5])
34+
false (bounds/contain-point? [0 0 10 10] [5 -5]))))
3235

3336
(deftest test-center
3437
(testing "center of bounds"

test/element_test.cljs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(ns element-test
2+
(:require
3+
[cljs.test :refer-macros [deftest testing are]]
4+
[renderer.tool.core]
5+
[renderer.utils.element :as element]))
6+
7+
(deftest test-root?
8+
(testing "is root element"
9+
(are [x y] (= x y)
10+
true (element/root? {:type :element :tag :canvas})
11+
false (element/root? {:type :element :tag :rect}))))
12+
13+
(deftest test-supported?
14+
(testing "supported elements"
15+
(are [x y] (= x y)
16+
true (element/supported? {:type :element :tag :rect})
17+
false (element/supported? {:type :element :tag :foo}))))

0 commit comments

Comments
 (0)