chore: add spec test for keycard component (#15920)

This commit is contained in:
Jamie Caprani 2023-05-19 12:45:47 +01:00 committed by GitHub
parent 62945205a0
commit 77ddd8688f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 15 deletions

View File

@ -1,20 +1,11 @@
(ns quo2.components.keycard.component-spec (ns quo2.components.keycard.component-spec
(:require [quo2.components.keycard.view :as keycard] (:require [quo2.components.keycard.view :as keycard]
[test-helpers.component :as h] [test-helpers.component :as h]))
[utils.i18n :as i18n]))
(h/describe "keycard component" (h/describe "keycard component"
(h/test "Render of keycard component when: Status = Empty, Locked = False" (h/test "Render of keycard component when: holder-name prop is not set"
(h/render [keycard/keycard]) (h/render [keycard/keycard])
(-> (h/expect (h/query-by-label-text :holder-name)) (h/is-truthy (h/get-by-translation-text :empty-keycard)))
(h/is-equal (i18n/label :t/empty-keycard)))) (h/test "Render of keycard component when: holder-name prop is set"
(h/render [keycard/keycard {:holder-name "Alisha"}])
(h/test "Render of keycard component when: Status = Filled, Locked = False" (h/is-truthy (h/get-by-translation-text :user-keycard))))
(h/render [keycard/keycard {:holder-name? "Alisha"}])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/user-keycard {:name :holder-name}))))
(h/test "Render of keycard component when: Status = Filled, Locked = True"
(h/render [keycard/keycard {:holder-name? "Alisha"}])
(-> (h/expect (h/query-by-label-text :holder-name))
(h/is-equal (i18n/label :t/user-keycard {:name :holder-name})))))

View File

@ -14,6 +14,7 @@
[quo2.components.drawers.drawer-buttons.component-spec] [quo2.components.drawers.drawer-buttons.component-spec]
[quo2.components.drawers.permission-context.component-spec] [quo2.components.drawers.permission-context.component-spec]
[quo2.components.inputs.input.component-spec] [quo2.components.inputs.input.component-spec]
[quo2.components.keycard.component-spec]
[quo2.components.inputs.profile-input.component-spec] [quo2.components.inputs.profile-input.component-spec]
[quo2.components.inputs.recovery-phrase.component-spec] [quo2.components.inputs.recovery-phrase.component-spec]
[quo2.components.inputs.title-input.component-spec] [quo2.components.inputs.title-input.component-spec]

View File

@ -188,6 +188,10 @@
[element] [element]
(.toBeTruthy (js/expect element))) (.toBeTruthy (js/expect element)))
(defn is-falsy
[element]
(.toBeFalsy (js/expect element)))
(defn is-null (defn is-null
[element] [element]
(.toBeNull (js/expect element))) (.toBeNull (js/expect element)))