|
| 1 | +(ns quo.components.text-combinations.standard-title.component-spec |
| 2 | + (:require [quo.components.text-combinations.standard-title.view :as standard-title] |
| 3 | + [test-helpers.component :as h])) |
| 4 | + |
| 5 | +(h/describe "Text combinations - Standard title" |
| 6 | + (h/test "Default render" |
| 7 | + (h/render [standard-title/view {:title "This is a title"}]) |
| 8 | + (h/is-truthy (h/get-by-text "This is a title"))) |
| 9 | + |
| 10 | + (h/test "Counter variant" |
| 11 | + (h/render [standard-title/view |
| 12 | + {:title "This is a title" |
| 13 | + :right :counter |
| 14 | + :counter-left 50 |
| 15 | + :counter-right 100}]) |
| 16 | + (h/is-truthy (h/get-by-text "50/100"))) |
| 17 | + |
| 18 | + (h/describe "Action variant" |
| 19 | + (h/test "Default render" |
| 20 | + (let [on-press-fn (h/mock-fn)] |
| 21 | + (h/render [standard-title/view |
| 22 | + {:title "This is a title" |
| 23 | + :right :action |
| 24 | + :on-press on-press-fn}]) |
| 25 | + (h/is-truthy (h/get-by-text "This is a title")))) |
| 26 | + |
| 27 | + (h/test "Action fired" |
| 28 | + (let [on-press-fn (h/mock-fn)] |
| 29 | + (h/render [standard-title/view |
| 30 | + {:title "This is a title" |
| 31 | + :right :action |
| 32 | + :on-press on-press-fn}]) |
| 33 | + |
| 34 | + (h/fire-event :on-press (h/get-by-label-text :standard-title-action)) |
| 35 | + (h/was-called-times on-press-fn 1)))) |
| 36 | + |
| 37 | + (h/describe "Tag variant" |
| 38 | + (h/test "Default render" |
| 39 | + (h/render [standard-title/view |
| 40 | + {:title "This is a title" |
| 41 | + :right :tag}]) |
| 42 | + (h/is-truthy (h/get-by-text "This is a title"))) |
| 43 | + |
| 44 | + (h/test "Tag callback fired" |
| 45 | + (let [on-press-fn (h/mock-fn)] |
| 46 | + (h/render [standard-title/view |
| 47 | + {:title "This is a title" |
| 48 | + :right :tag |
| 49 | + :on-press on-press-fn}]) |
| 50 | + (h/fire-event :on-press (h/get-by-label-text :standard-title-tag)) |
| 51 | + (h/was-called-times on-press-fn 1))))) |
0 commit comments